Ever feel stupid?
I have a vbscript that copies a series of files from one server to another (don’t ask why!) that runs using a scheduled task
Now if i run the script manually all works fine. If i run the scheduled task manually all works fine.
However, every week when i expect the data to have been copied nothing happens
I’ve simplified the code for posting purposes as the code also does some logging and error checking
SourceFolderPath = “S:\Images\System\”
set FSO = CreateObject(“Scripting.FileSystemObject”)
set SourceFolderObj = FSO.GetFolder(SourceFolderPath)
Set DestinationFolderObj = FSO.GetFolder(DestinationFolderPath)
”Empty Destination Directory
For each LoopFile in DestinationFolderObj.Files
LoopName = LoopFile.name
For each LoopFile in SourceFolderObj.Files
Can anyone tell me why this fails?
I had a eureka moment this morning
The source folder is on drive S:
Which exists when i run the script manually. But it doesn’t exist when i’m logged off
So i added the following
strDriveLetter = “S:”
strRemotePath = “\\Server\Share
strUser = “someuser”
strPassword = “somepassword”
strProfile = “false”
Set objNetwork = WScript.CreateObject(“WScript.Network”)
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath,strProfile, strUser, strPassword
Not entirely sure why i didn’t spot this earlier but needless to say when i did i felt like giving myself a kick!
Latest posts by Andy Parkes (see all)
- My Year In Running – 2017 - January 1, 2018
- Run For Your Life – A Magazine About Everyday Runners - December 9, 2017
- DNS Server Can’t Resolve Against Itself - December 6, 2017