hehe... jeg har skiftet hele scriptet ud nu :-) og det virker bedre, dog vil det ikke tildele printere... så i får lige det nye script at kigge på....
'==========================================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR: PM
' DATE : 24/01/2008
'
' COMMENT: Enumerates current users' group memberships in given domain.
' Maps and disconnects drives and printers
'
'==========================================================================
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically grab the user's domain name
DomainString = Wshnetwork.UserDomain
'Find the Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'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
'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 "M:", "\\Lserver-2005\download",True
WSHNetwork.MapNetworkDrive "S:", "\\Lserver-2005\sysadmin",True
WSHNetwork.MapNetworkDrive "T:", "\\Lserver-2005\arrangementer",True
WSHNetwork.MapNetworkDrive "U:", "\\Lserver-2005\admin",True
WSHNetwork.MapNetworkDrive "V:", "\\Lserver-2005\billed",True
WSHNetwork.MapNetworkDrive "W:", "\\Lserver-2005\data",True
WSHNetwork.MapNetworkDrive "X:", "\\Lserver-2005\insys",True
WSHNetwork.MapNetworkDrive "Z:", "\\Lserver-2005\glproj",True
'Now check for group memberships and map appropriate drives
'Note that this checks Global Groups and not domain local groups.
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
'Note the use of all upper case letters as mentioned above.
'Note also that the groups must be Global Groups.
Case "01 Ledelse"
WSHNetwork.MapNetworkDrive "Y:", "\\Lserver-2005\fortroligt",True
WSHNetwork.MapNetworkDrive "N:", "\\Lserver-2005\boghold",True
Case "02 Boghold"
WSHNetwork.MapNetworkDrive "N:", "\\Lserver-2005\boghold",True
'Below is an example of how to set the default printer
WSHNetwork.SetDefaultPrinter "\\Lserver-2005\SortHvid"
Case "03 Kontor"
WSHNetwork.MapNetworkDrive "Y:", "\\Lserver-2005\fortroligt",True
WSHNetwork.SetDefaultPrinter "\\Lserver-2005\Farve"
Case "04 Projekt"
WSHNetwork.SetDefaultPrinter "\\Lserver-2005\Farve"
Case "05 Domain help"
WSHNetwork.MapNetworkDrive "Y:", "\\Lserver-2005\fortroligt",True
WSHNetwork.SetDefaultPrinter "\\Lserver-2005\Farve"
End Select
Next
'Remove a specific printer
WSHNetwork.RemovePrinterConnection "\\Lserver-2005\SortHvid",True,True
WSHNetwork.RemovePrinterConnection "\\Lserver-2005\Farve",True,True
'Install A Printer
WSHNetwork.AddWindowsPrinterConnection "\\Lserver-2005\sorthvid"
WSHNetwork.AddWindowsPrinterConnection "\\Lserver-2005\farve"
'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