Deleting Printers

in Off-Topic
We have a script that maps printers for the users when they log on. What we want to do is deploy the printers using GPO instead. So i have built a 2008 print server, and configured all the printers to be deployed using GPO. My question is how can i delete the old mapped printers and use the GPO instead?
Comments
-
Devilsbane Member Posts: 4,214 ■■■■■■■■□□
How about a logon script that deletes all printers? You could stick it in the run once section of the registry.
You could use a tool like psexec to deploy it out to all machines.Decide what to be and go be it. -
billybob01 Member Posts: 504
Yes, i was thinking the same but i am not a scripting guy so i would not know what to add to the script. -
crrussell3 Member Posts: 561
Why not use Group Policy Preferences to delete the printer? I would also use it to add them. Otherwise a quick vbs script will do the trick.MCTS: Windows Vista, Configuration
MCTS: Windows WS08 Active Directory, Configuration -
RomBUS Member Posts: 699 ■■■■□□□□□□
Try this I found (test it first):
rundll32 printui.dll,PrintUIEntry /dn /q /n "UNC path of shared printer" (without quotes)
For example:
rundll32 printui.dll,PrintUIEntry /dn /q /n \\server1\HP Generic Printer
You can include in the same script as the one you have for the additions of the printer -
rjs_essex Member Posts: 57 ■■□□□□□□□□
If you want to script it, you can reverse the installation with a vb script at logoff. An old method I used before deploying via GP was with VB Scripts... Create a batch file that contains the following:
net use z: /d >nul
net use z: \\UNC /y >nul
wscript.exe //nologo //B z:\remove.vbs
net use z: /delete
(Where 'z' is a drive letter not in use, 'UNC' is a network share hosting your scripts and 'remove.vbs' is the name of the script to remove the printers)
Then in the script share location create a vb script with the following code:
dim WshNetwork
set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath1 = "\\UNC1"
WshNetwork.RemovePrinterConnection PrinterPath1
(Where 'UNC1' is the share name of the printer)
There is most definately more streamlined ways of doing it but if you want to script it (in a reletively simple way) this worked perfectly for me back in the day! Of course, you can add as many printer connections to the vbscript as you like just declare them with a differnet PrinterPath number.
PrinterPath1 = "\\UNC1"
PrinterPath1 = "\\UNC2"
WshNetwork.RemovePrinterConnection PrinterPath1
WshNetwork.RemovePrinterConnection PrinterPath2
Etc, etc...
You could also make the batch file more complex by calling the computer name and then calling different scripts for different sets of computers. But in your case, to remove them all in one go a single vb script should suffice.
Hope that helps!WIP: 70-417, Security+, Project+, CCNA