Windows 8: Task Scheduler Mapping Network drive with batch file or VBS

812 views Asked by At

I am trying to schedule a task on my Windows 8.1 Laptop that i use both for office and home use. I wish to automatically map my network drives when i connect to my home network. The task scheduling part is working however when the batch file is called I see no errors everything is a success but i see no mapped drives in my explorer. When i run the batch file directly by double clicking it works fine and adds the mapped drives.

timeout 10
net use X: /DELETE
net use Y: /DELETE
net use Z: /DELETE
net use X: \\hostname\folder1 /user:username password /PERSISTENT:NO
net use Y: \\hostname\folder2 /user:username password /PERSISTENT:NO
net use Z: \\hostname\folder3 /user:username password /PERSISTENT:NO

I have also tried calling a VBScript with the same result. The script works directly but gives an error if called from scheduler "The local device name is already in use"

Dim objNetwork, strLocalDrive, strRemoteShare
Set objNetwork = WScript.CreateObject("WScript.Network")
strLocalDrive = "H:"
strRemoteShare = "\\myserver\users" 
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, False, "username", "password"
Set objNetwork = Nothing

Please help me out with a solution.

1

There are 1 answers

0
Daniel On

the only way i was able to do this automaticaly is by using Active Directory or by clicking myself on the script file. for some reason, Windows 8.1 don't execute script, by task scheduler or by GPO when it's about connecting network drive. you have to use the user properties "Logon script" from the "profil" tab in the user properties.

i hope that's can help you