[英]Checking for old and new file, creating one if nothing exists with vbscript
因此,我正在嘗試為Windows編寫腳本,以檢查用戶是否同時存在舊的和新的Outlook配置文件。 如果存在舊文件,但不存在新文件,它將復制舊文件並為其提供新的文件名。
我對語法有一個大致的了解,看起來像這樣。
If Exist \users\%%UserName%%\%%OldFileName%%
If NOT Exist \users\%%UserName%%\%%NewFileName%%
copy \users\%%UserName%%\%%OldFileName%% \users\%%UserName%%\%%NewFileName%%
End If
End If
更新!
到目前為止,這是我能想到的。
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
strOldFileName = “Default Outlook Profile.NK2”
strNewFileName = “Default Profile.NK2”
If objFSO.FileExists "\\comfilesrv1\users\%%UserName%%\&OldFileName&" Then
objFSO.CopyFile "\\comfilesrv1\users\%%UserName%%\&OldFileName&", "\\comfilesrv1\users\%%UserName%%\&NewFileName&"
End If
我並沒有要求任何人為我寫這篇文章,但是如果有人可以指出我正確的方向,那將很棒。
嘗試這個
Dim objFSO, strOldFileName, strNewFileName, strOldProfile, strNewprofile, bOverwrite
Set objFSO = CreateObject("Scripting.FileSystemObject")
bOverwrite = true
strOldFileName = "Default Outlook Profile.NK2"
strNewFileName = "Default Profile.NK2"
strOldProfile = "\\comfilesrv1\users\" & UserName & "\" & strOldFileName
strNewprofile = "\\comfilesrv1\users\" & UserName & "\" & strNewFileName
If objFSO.FileExists(strOldProfile) Then
objFSO.CopyFile strOldProfile, strNewprofile, bOverwrite
End If
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.