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!

Problem with script for mapping drives

Status
Not open for further replies.

rmwendwa

MIS
Mar 23, 2005
22
0
0
KE
I have edited the script below to meet my user needs. its for a small college and all students belong to a group called students for easy administration. Now these students also belong to other seperate groups apart from the students group depending on the courses they are taking e.g information technology, library studies etc. now when a user logs in he can view his home folder located on the path \\server01\students home$\%username% - drive G:, the students common folder on the path \\server01\users$\students folder - drive H:, but the drive I: which i have created for them depending on the groups there in (that is course) is not mapping. Is there an error on my script. help me out

ON ERROR RESUME NEXT

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, Groupobj, UserObj, Path


Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

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

'Map drives needed by all
WSHNetwork.MapNetworkDrive "G:", "\\server01\students home$\%username%",True
WSHNetwork.MapNetworkDrive "H:", "\\server01\users$\Students Folder",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
Case "InformationTechnology"
WSHNetwork.MapNetworkDrive "I:", "\\Server01\users$\Information Technology",True
Case "BusinessStudies"
WSHNetwork.MapNetworkDrive "I:", "\\Server01\users$\Business Studies",True
Case "LibraryStudies"
WSHNetwork.MapNetworkDrive "I:", "\\Server01\users$\Library Studies",True
Case "SecretarialStudies"
WSHNetwork.MapNetworkDrive "I:", "\\Server01\users$\Secretarial Studies",True
End Select
NEXT

'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

 
Use a print statement after "Userstring" to display what it is holding,and then you would know if it is doing as you except to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top