I need help with a VB Script to remove network printers

MrEgo

Senior member
Jan 17, 2003
874
0
76
Here's the situation. I just put together a new print server, so we need to create some scripts to remove all of the printers that are currently installed on our users' PCs. I'm not having any problems with the script to add the new printers, but removing the old printers has been a huge pain in the butt.

Here's an example of a login script to connect to the old print server for a particular set of users:

'
' Printers.vbs - Windows Logon Script.
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\(servername)\tek_Dell3110cn_IT"
objNetwork.AddWindowsPrinterConnection "\\(servername)\tek_canonIR3220Color_CopyRoom"
objNetwork.AddWindowsPrinterConnection "\\(servername)\tek_canonIR3220_AlwaysColor"
objNetwork.AddWindowsPrinterConnection "\\(servername)\tek_CanonIR6570_CopyRoom"


So by looking at the current login script, can anyone tell me where to begin to remove all network printers from our users' printer list?

Thanks in advance!
 

MrEgo

Senior member
Jan 17, 2003
874
0
76
Thanks for the help guys. I used this script:


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Network = TRUE")

For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next

Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\(servername)\Tek_ITOffice_3110cn"
objNetwork.AddWindowsPrinterConnection "\\(servername)\Tek_CopyRoom_BW6570"
objNetwork.AddWindowsPrinterConnection "\\(servername)\Tek_CopyRoom_Color3220"


...and so on.

I'm going to run this script for about a week so that every user in the building will most likely run it at LEAST once to clear off all of the old printers from the old print server. Problem is, we have local printers such as "Send to OneNote", etc, and the default printer keeps being reset to these local printers after every startup. Is there a way to set a default printer in a script? It looks like there is, but once again.. I can't find anything that works that I can add into my current script..

Thanks again in advance.