TechieSooner
Supreme [H]ardness
- Joined
- Nov 7, 2007
- Messages
- 7,601
This works in XP.
On Vista, it does not work at all... Sure some of this is bad with Vista, so my question is how do I fix it but it works in both XP/Vista?
On Vista, it does not work at all... Sure some of this is bad with Vista, so my question is how do I fix it but it works in both XP/Vista?
Code:
'MAP THE PRINTERS
Set objNetwork = CreateObject("WScript.Network")
Dim objNetwork, strLocal, strUNCPrinter1, strUNCPrinter2
strUNCPrinter1 = "\\server\prt1"
strUNCPrinter2 = "\\server\prt2"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter1
objNetwork.AddWindowsPrinterConnection strUNCPrinter2
'SET DEFAULT PRINTER BASED ON GROUP MEMBERSHIP
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
Select Case strGroupName
Case "Printer 1 Users"
objNetwork.SetDefaultPrinter "\\server\prt1"
Case "Printer 2 Users"
objNetwork.SetDefaultPrinter "\\server\prt2"
End Select
Next
'MAP THE DRIVES
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "R:" , "\\server\share1"
objNetwork.MapNetworkDrive "W:" , "\\server\share2"
objNetwork.MapNetworkDrive "X:" , "\\server\share3"