Logon script to map network drive

Associate
Joined
6 Feb 2004
Posts
689
Location
Herts
Hi all,

Been playing with some logon scripts this afternoon to try an map a pre-defined set of network drives for our users.

I started with the NET USE command in a batch file and this worked with some success, but failed when i need to provide user credentials.

So i moved to a VBS script which also seems to work ok but i'm coming across some very strange quirks...

Firstly, the script only seems to work for any one who has mapped the network resource in the past. If i apply the script to a new user account (with no cached connections etc) it does not work. If i browse the resources in question and then run the script again the drives map fine.

Any idea what i'm doing wrong?

The script i'm using is:

' map-network-drive.vbs
' VBScript to map a network drive
' ----------------------------------------------------------------------'
Option Explicit
Dim objNetwork
Dim strDriveLetter1, strRemotePath1
Dim strDriveLetter2, strRemotePath2

' Values of variables set
strDriveLetter1 = "w:"
strRemotePath1 = "\\172.16.100.42\d$"


strDriveLetter2 = "T:"
strRemotePath2 = "\\172.16.100.52\d$"


Set objNetwork = WScript.CreateObject("WScript.Network")

' Part that maps the network drive
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
 
Soldato
Joined
12 Jan 2006
Posts
5,610
Location
UK
Why don't you setup AD groups and apply them to the folder you wish. Add the user into the group and then write the script to suit the groups.
 
Soldato
Joined
12 May 2005
Posts
8,384
Try adding a secondary share name instead of using the default admin shares. Without the hidden $, just to see if something is blocking a mapping directly without cached credentials already in place.
 
Back
Top Bottom