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

Logon script for markdmac

Status
Not open for further replies.

Leke

IS-IT--Management
Aug 19, 2005
22
0
0
NG
Hi all,

I implemented this following script on my domain:

ON ERROR RESUME NEXT

Set WSHShell = CreateObject("WScript.Shell")
Set objNet = CreateObject("WScript.Network")
DomainString = "ZSWSDMN"
UserString = objNet.UserName

'Synchronizes PC's With Time Server
WSHShell.Run "NET TIME \\ZSWSDMN01 /set /y"

'All Users Drive Mappings
objNet.MapNetworkDrive "H:", "\\DC\data",True


'Group Membership Drive Mappings
'Check Group Memberships
If IsMember(objUser, "Administrators") Then
objNet.MapNetworkDrive "L:", "\\DC",True
objNet.MapNetworkDrive "M:", "\\DC\Data",True


End If

If IsMember(objUser, "test1") And IsMember(objUser, "Administrators") Then
objNet.MapNetworkDrive "I:", "\\DC\operations",True

End If



wscript.quit.

Result:

There was no mapped drive in "My Computer" of a client marchine when domain users and administrators logs on to domain.

On the contrary, there were mapped drives when domain administrators log on to domain through domain controller.

What I want: How can I edit this script to enable users in test1 group to have mapped drive on their machine when they log on to domain through their computer.

Thank you very much.

Leke
 
DomainString = objDomain.Get("dnsHostName")

'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName


'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\Server /set /y"

'Disconnect any drive mappings as needed.
WSHNetwork.RemoveNetworkDrive "F:", True, True

'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next

'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300

'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
WSHNetwork.MapNetworkDrive "H:", "\\domainserver\operations\" & UserString,True
WSHNetwork.MapNetworkDrive "U:", "\\domainserver\legal",True
WSHNetwork.MapNetworkDrive "X:", "\\domainserver\payroll",True

'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'Check for group memberships and take needed action
'In this example below, ADMINISTRATORS and TEST1 are groups.
Case "Administrators"
WSHNetwork.MapNetworkDrive "w:", "\\domainserver\legal",True
Case "test1"
WSHNetwork.MapNetworkDrive "w:", "\\netcom-fs\payroll",True

End Select

'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing


'Quit the Script
wscript.quit

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top