Scripts Thread, Script to delete all network printers at logoff? in Coding and Web Development; Anyone know of simple script to delete all Network printers (not local ones) at logoff. We run a script to ...
-
17th November 2005, 11:32 AM #1
- Rep Power
- 0
Script to delete all network printers at logoff?
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
-
-
IDG Tech News
-
17th November 2005, 11:43 AM #2 Re: Script to delete all network printers at logoff?
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
-
-
17th November 2005, 11:44 AM #3
- Rep Power
- 0
Re: Script to delete all network printers at logoff?
Thanks, I will try this later today!
-
-
17th November 2005, 11:53 AM #4 Re: Script to delete all network printers at logoff?
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
-
-
17th November 2005, 11:54 AM #5 Re: Script to delete all network printers at logoff?
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
-
-
17th November 2005, 12:16 PM #6
- Rep Power
- 0
Re: Script to delete all network printers at logoff?
you could just cheat and use con2prt and run:
Code:
\\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?)
-
-
17th November 2005, 12:51 PM #7 Re: Script to delete all network printers at logoff?
Because Microsoft say so!
-
-
27th November 2005, 10:41 PM #8
- Rep Power
- 0
Re: Script to delete all network printers at logoff?

Originally Posted by
E1uSiV3 you could just cheat and use
con2prt and run:
Code:
\\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...
www.henrymellish.com/adprintx.zip
sorry DMccoy, advertising again.. I work for Microsoft :P
-
SHARE: 
Similar Threads
-
By woody in forum Windows
Replies: 74
Last Post: 15th February 2013, 02:28 PM
-
By philtomo-25 in forum Scripts
Replies: 2
Last Post: 1st November 2007, 03:50 PM
-
By roland in forum How do you do....it?
Replies: 11
Last Post: 20th September 2007, 09:43 PM
-
By Jonny_sims in forum Scripts
Replies: 11
Last Post: 14th June 2007, 02:54 PM
-
By tosca925 in forum Scripts
Replies: 2
Last Post: 31st August 2005, 07:45 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules