netuse.bat and Map.vbs (Create Map Drive from Group Policy)

create map drive for domain user from Group policy .bat

net use L: \\Servername\share

create map drive for domain user from Group policy .vbs

Option Explicit

Dim strDriveLetter, strRemotePath, strUserName
Dim objNetwork, objShell
Dim CheckDrive, AlreadyConnected, intDrive
strDriveLetter = “H:”
strRemotePath = “\\servername”
Set objShell = CreateObject(“WScript.Shell”)
Set objNetwork = CreateObject(“WScript.Network”)
Set CheckDrive = objNetwork.EnumNetworkDrives()
On Error Resume Next
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count – 1 Step 2
 If CheckDrive.Item(intDrive) =strDriveLetter _
 Then AlreadyConnected =True
Next
If AlreadyConnected = False then
 strUserName = objNetwork.UserName
 objNetwork.MapNetworkDrive strDriveLetter, strRemotePath _
 & “\” & strUserName
End if

WScript.Quit

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: