woody Posted November 17, 2005 Posted November 17, 2005 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
Guest Posted November 17, 2005 Posted November 17, 2005 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
Geoff Posted November 17, 2005 Posted November 17, 2005 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?name=Forums&file=viewtopic&t=404
DMcCoy Posted November 17, 2005 Posted November 17, 2005 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
E1uSiV3 Posted November 17, 2005 Posted November 17, 2005 you could just cheat and use con2prt and run: \\Server\Share\Con2Prt.exe /F This will remove all network (but not local) printers (yes i know its an NT4 tool, but it works perfectly here and does not require big VBS scripts, why reinvent the wheel?)
Geoff Posted November 17, 2005 Posted November 17, 2005 why reinvent the wheel? Because Microsoft say so!
jonny_valentine Posted November 27, 2005 Posted November 27, 2005 you could just cheat and use con2prt and run: \\Server\Share\Con2Prt.exe /F This will remove all network (but not local) printers (yes i know its an NT4 tool, but it works perfectly here and does not require big VBS scripts, why reinvent the wheel?) I agree, con2prt works great for me, and adprintX is even better, i dont have a preference... http://www.henrymellish.com/adprintx.zip sorry DMccoy, advertising again.. I work for Microsoft
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now