Board index » Visual Studio » Trying to get MapNetworkDrive-related vbscript to work with Scheduled Task

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.


-
 

Re:Trying to get MapNetworkDrive-related vbscript to work with Scheduled Task

Hi Tod,



Unfortunattly I don't have any answer for you but I am experincing the exact same think so I'm very interested in a possible solution.



The weird thing for me is that the scheduled task can sometimes work but then suddenly stop working. Somtimes a restart of the computer solves it, sometimes not.

-