Is there an alternative command I should be using to unmap a network
printer from a user's workstation? The workstations in question are
running Windows XP Pro SP2 with all the most current updates.
Let's have a look at your "RemovePrinter" script! Alternatively
you could use this command:
net use \\Servername\Printername /del
Adding a Printer:
if isMember("Domain Users") then
AddPrinter "\\server1\Printer1" ' Create printer1
writeLog "Mapped Printer1"
End if
Removing a Printer:
if isMember("Domain Users") then
RemovePrinter "\\server1\Printer1" ' Remove Printer1
writeLog "Removed Printer1"
End if
"Rob Gordon" <Robert...@nospam.dslextreme.com> wrote in message
news:478A6BA7...@nospam.dslextreme.com...
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"Pegasus (MVP)" <I....@fly.com.oz> wrote in message
news:%23EP4ZCi...@TK2MSFTNGP05.phx.gbl...
Dim objSysInfo, strUserDN, objUser, objNetwork, objGroup
' Bind to local user object.
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUserDN)
' Bind to wshNetwork object.
Set objNetwork = CreateObject("Wscript.Network")
' Bind to group object to check membership.
Set objGroup = GetObject("LDAP://cn=Sales,ou=West,dc=MyDomain,dc=com")
' Check if user a member of the group.
If (objGroup.IsMember(objUser.AdsPath) = True) Then
' Remove a printer connection.
objNetwork.RemovePrinterConnection "\\MyServer\Laser1", True, True
' Add a printer connection.
objNetwork.AddWindowsPrinterConnection "\\MyServer\Laser3"
' Set default printer.
objNetwork.SetDefaultPrinter "\\MyServer\Laser3"
End If
Thanks much!
Rob