Board index » Visual Studio » Trying to get MapNetworkDrive-related vbscript to work with Scheduled Task
|
dev_cool
|
Trying to get MapNetworkDrive-related vbscript to work with Scheduled Task
Visual Studio289
I have a script that maps a drive to a network path, supplying the username and password, copies a file to that path, then disconnects from the path. It runs fine. Now I want a scheduled task to run the file overnight. The scheduled task does not seem to run the file. My code looks like this: Dim filesys Dim objNet Set objNet = CreateObject("WScript.Network") '"\\xyz001\Folder" is the network path I want to map to. "ABC1\UserName" is the domain and username I use when manually mapping to the path. objNet.MapNetworkDrive "l:", "\\xyz001\Folder", False, "ABC1\UserName","Password" Set filesys = CreateObject("Scripting.FileSystemObject") filesys.CopyFile "C:\MyFolder\MyFile.xls", "l:\MyFile.xls" objNet.RemoveNetworkDrive "l:" When I create the scheduled task, I supply my credentials used for logging in to the machine where the task is running. Is that where the problem is? I barely know what I'm doing, so I hope someone reading this knows what I'm doing. - |
