Anyone know of simple script to delete all Network printers (not local ones) at logoff. We run a script to add a printer based on machine name but when we occasionally swap a printer in a room and update the script, the old printer driver is left over and these can build up over time.
Thanks
Paste the following into notepad:
Option Explicit
Dim DelPrint, UNCpath
UNCpath = "\\%SERVER%\%PRINTER%"
On Error Resume next
Set DelPrint = WScript.CreateObject("WScript.Network")
DelPrint.RemovePrinterConnection UNCpath, true, true
WScript.Quit
Change the UNCpath to point to your printer.
Save it as a .vbs file and volia
Thanks, I will try this later today!
You might want to look at Ric's printer script. He has a while loop at the start of it to delete all the network printers.
http://www.edugeek.net/index.php?nam...iewtopic&t=404
This is based on the portname from the print server. It removes all printers that end in .local and .school. Not sure if it works, I've taken it from a bigger script
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WS_PRINTERS = WshNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WS_PRINTERS.Count - 1 Step 2
IF Lcase(right(WS_PRINTERS.Item(LOOP_COUNTER),6)) = "school" THEN
WshNetwork.removeprinterconnection WS_PRINTERS(LOOP_COUNTER+1), true
End If
IF Lcase(right(WS_PRINTERS.Item(LOOP_COUNTER),5)) = "local" THEN
WshNetwork.removeprinterconnection WS_PRINTERS(LOOP_COUNTER+1), true
End If
Next
Set WS_PRINTERS = Nothing
you could just cheat and use con2prt and run:
This will remove all network (but not local) printersCode:\\Server\Share\Con2Prt.exe /F
(yes i know its an NT4 tool, but it works perfectly here and does not require big VBS scripts, why reinvent the wheel?)
Because Microsoft say so!why reinvent the wheel?![]()
I agree, con2prt works great for me, and adprintX is even better, i dont have a preference...Originally Posted by E1uSiV3
www.henrymellish.com/adprintx.zip
sorry DMccoy, advertising again.. I work for Microsoft :P
There are currently 1 users browsing this thread. (0 members and 1 guests)