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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't map network drive from task scheduler - was working

Status
Not open for further replies.

raphael75

Programmer
Nov 15, 2012
67
US
We have a vbs file on our local server (A) that uses mapnetworkdrive to contact two servers at a remote location (B) and copy files from B to A. The script has been running for about 3 months with no problems. Since last week, the script has been unable to map the network drive to B if it runs from Task Scheduler, but it works fine when run from the command line or by double-clicking on the vbs file.

What could cause the scheduled task to not be able to map the network drive but it still works by manually executing it?

When you double-click or CLI execute a vbs file, what user account does it run under? Is it different from the user account that runs it from Task Scheduler?

Thanks!
 
What could cause the scheduled task to not be able to map the network drive but it still works by manually executing it?
In my experience, a script can only run in the task manager (win7-) when passed as an argument to wscript.exe.

When you double-click or CLI execute a vbs file, what user account does it run under? Is it different from the user account that runs it from Task Scheduler?
Yes. The script will always run as you except when otherwise specified; Task Scheduler is one of these exceptions.

-Geates

 
In my experience, a script can only run in the task manager (win7-) when passed as an argument to wscript.exe.

I know the script is running because it logs things as it runs. One of those is the error message when it tries to map the network drive. It looks like this:

Code:
boh_mapped_drive_letter = "w:"
boh_mapped_drive = "\\xxx.xxx.xxx.xxx\sharename"
NetworkObject.MapNetworkDrive boh_mapped_drive_letter, boh_mapped_drive, False,  <username>, <password>
if err.number <> 0
     appendToFile logfile, vbtab & "error occurred - " & vbtab & err.number & " " & err.source & " " & err.description
     Err.Clear
end if

and the error I get is:

53 Microsoft VBScript runtime error File not found

However, I know the folder exists, and it works if I double-click or command line execute the .vbs file.
 
Looks like we were able to fix it by checking the "Run with Highest Privileges" box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top