Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbs runs by double clicking, freezes when run from task scheduler

Status
Not open for further replies.

raphael75

Programmer
Nov 15, 2012
67
0
0
US
I have a .vbs script that copies files from multiple remote computers. Each server has a shared folder that I map as a network drive (W:). When I run it by double-clicking, it runs fine, but if I run it from Task Scheduler (Win Server 2003) it hangs on this line:

Code:
NetworkObject.MapNetworkDrive "W:", "\\xxx.xxx.xxx.xxx\sharename", false, <username>, <password>

I've tried everything but I can't figure out why it won't run in task scheduler. Please help!
 
In the Scheduled Task window, in the "Start in:" text box, did you specify "cscript /nologo" ??

Code:
Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
strLocalDrive = "K:"
strRemoteShare = "\\myServer\Map\Vol1"
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, False

I just made the above script, and ran it on one of my WinXP machines, worked fine. Removed the Mapping, then added it to "Scheduled Tasks" and used "cscript /nologo" in the "Start in:" text box and it also worked.
 
It turned out to be an issue with the server not being rebooted in a long time. After restarting it worked. Thanks for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top