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

markdmac - scripts 1

Status
Not open for further replies.

rmwendwa

MIS
Mar 23, 2005
22
KE
I have used your script for setting proxy's which worked perfectly and it was to my enjoyment as i stated earlier. now am a fun of your scripts and i got this one for mapping drives and printers and i edited it to suit my needs - that is to map drives to certain users who belong to specific groups. like i said i've never worked with scripts before and its giving me an error on line 1 character 1 the error being "type mismatch:'script'". i have pasted my code you can check it out.


[script]

ON ERROR RESUME NEXT

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, 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)

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


'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
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

[/script]
 
You're not supposed to include the following in the script;

[script]

[/script]


Take both of those out.
 
thanks digitalcandy for your useful tip and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top