I am new to creating a vbs script to map network drives in windows. For some reason, the script runs, but does not map any network drives when a user logs on to the domain. Here is the script I am using. It is pretty simple and straight forward.
Option Explicit
Dim wshNetwork
Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "S:","\\server\shared"
wshNetwork.MapNetworkDrive "U:","\\server\" & wshNetwork.UserName
WScript.Quit
What am I doing wrong?
Try:
I also add a routine to remove all the shares just to avoid "device is already in use" errors that I was getting, prior to mapping the drives.
Here's a function I've been using:
Usage example: