mtbrain200
MIS
I want to thank everyone up front. I have a script where I am checking for the existence of a file, if not found copy some other files from one server location to another, then copy a link file to the desktop. The first copy seems to work, but then the script goes back to the main script and does not perform the other copies. Any suggestions would be appreciated.
CODE:
Option Explicit
Const OverwriteExisting = True
Dim objFSO, WSHShell, WSHEnv, sUserName, Mail6location, bMail6Exists
' ************ Start Span *****************
call getuser()
filecheck()
' Sub to get the username
sub getuser()
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHEnv = WSHShell.Environment("Process")
sUserName = WSHEnv("USERNAME")
'msgbox sUserName
end sub
' Sub to check for the file
sub filecheck()
If NOT objFSO.FileExists("\\server1\r_mydocuments$\" & sUserName & "\Notes\Data\Mail6.ntf") Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
msgbox "begin copy routine 1"
objFSO.CopyFile "\\server1\r_mydocuments$\N6ntf\*.ntf" , "\\server1\r_mydocuments$\" & sUserName & "\Notes\Data\" , OverwriteExisting
msgbox "begin copy routine 2"
objFSO.CopyFile "\\server1\r_mydocuments$\" & sUserName & "\Notes\notes.ini" , "\\server1\r_mydocuments$\" & sUserName & "\Notes\Data\notes.ini"
msgbox "begin copy routine 3"
objFSO.CopyFile "\\server1\notes601$\*.lnk" , "C:\Docume~1\" &sUserName& "\desktop\" , OverwriteExisting
Else
cscript.quit
End If
Msgbox "end sub filecheck"
end sub
set WSHShell = nothing
set WSHEnv = nothing
set objFSO = nothing
msgbox "script complete"
' End script
CODE:
Option Explicit
Const OverwriteExisting = True
Dim objFSO, WSHShell, WSHEnv, sUserName, Mail6location, bMail6Exists
' ************ Start Span *****************
call getuser()
filecheck()
' Sub to get the username
sub getuser()
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHEnv = WSHShell.Environment("Process")
sUserName = WSHEnv("USERNAME")
'msgbox sUserName
end sub
' Sub to check for the file
sub filecheck()
If NOT objFSO.FileExists("\\server1\r_mydocuments$\" & sUserName & "\Notes\Data\Mail6.ntf") Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
msgbox "begin copy routine 1"
objFSO.CopyFile "\\server1\r_mydocuments$\N6ntf\*.ntf" , "\\server1\r_mydocuments$\" & sUserName & "\Notes\Data\" , OverwriteExisting
msgbox "begin copy routine 2"
objFSO.CopyFile "\\server1\r_mydocuments$\" & sUserName & "\Notes\notes.ini" , "\\server1\r_mydocuments$\" & sUserName & "\Notes\Data\notes.ini"
msgbox "begin copy routine 3"
objFSO.CopyFile "\\server1\notes601$\*.lnk" , "C:\Docume~1\" &sUserName& "\desktop\" , OverwriteExisting
Else
cscript.quit
End If
Msgbox "end sub filecheck"
end sub
set WSHShell = nothing
set WSHEnv = nothing
set objFSO = nothing
msgbox "script complete"
' End script