So I'm trying to write a script for Windows to check and see if both an old and a new outlook profile exists for a user. If an old one exists but a new one doesn't, it copies the old one and gives it a new file name.
I have a general idea of the syntax, looks something like this.
If Exist \users\%%UserName%%\%%OldFileName%%
If NOT Exist \users\%%UserName%%\%%NewFileName%%
copy \users\%%UserName%%\%%OldFileName%% \users\%%UserName%%\%%NewFileName%%
End If
End If
UPDATED!
Here's what I've been able to come up with so far.
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
I'm not asking for anyone to write this for me, but if someone could point me in the right direction, that would be great.
Try this
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