Delete Printer via Group Policy
We are replacing one of our office copiers and I would like to add a line to our logon script that delete the printer at logon.
I'm currently using the following line but it doesnt seem to be working:
Net Use Canonirc / Delete
I'm currently using the following line but it doesnt seem to be working:
Net Use Canonirc / Delete
Comments
-
qwertyiop Member Posts: 725 ■■■□□□□□□□I endedup using the following instead but I still have one more problem.
rundll32 printui.dll,PrintUIEntry /dn /n \\server\printername
I dont want it to run if the printer doesnt exist. I would like to use the IF EXISTS command but first I need a way to see if the printer is actually installed. Do any of you have any ideas? -
Hyper-Me Banned Posts: 2,059Do you guys not make use of Group Policy Preferences CSEs?
I dont know what id do without them. -
qwertyiop Member Posts: 725 ■■■□□□□□□□Do you guys not make use of Group Policy Preferences CSEs?
I dont know what id do without them.
I never heard of it -
NightShade03 Member Posts: 1,383 ■■■■■■■□□□You can use the following as part of a logon script policy.
NOTE: This wasn't tested so please use with caution (although it should work no problem)On Error Resume Next ' This script will be run against the local computer strComputer = "." ' The next two set commands will query all the printers on the local computer Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") ' Iterate through the printers found For Each objPrinter in colInstalledPrinters ' Uncomment for some debugging (the printer's name) 'Wscript.Echo "Name: " & objPrinter.Name If objPrinter.Name == "Name_of_old_printer" Then objPrinter.Delete_ End If Next ' Once old printer is gone add the new one Set WshNetwork = CreateObject("WScript.Network") ' Uncomment the second line if you want to set the new printer as the default WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Name_of_new_printer" 'WshNetwork.SetDefaultPrinter "\\PrintServer1\Name_of_new_printer" Wscript.Quit
-
rwwest7 Member Posts: 300Group Policy Preference Client Side Extensions Available
You need a Vista computer in order to apply them, but they can be applied to XP and above as long as an update is installed.