PDA

View Full Version : Removing printers from client machines


DeaconFrost
10-16-2007, 10:01 AM
Is this possible to do remotely? I have a network printer that was installed on about 20 client PCs, that's no longer in existence. I could walk around and do it, but then I have to wait for everyone to let me sit at their desk. I know in the MMC, I can access other PCs, so I was looking for something similar to that. I have admin access to the domain.

QwertyJuan
10-16-2007, 11:45 AM
con2prt.exe

Download it.
Use it.
Thank me later! ;)

Syntax
CON2PRT /f
CON2PRT /c \\PrintServer\PrintShare
CON2PRT /cd \\PrintServer\PrintShare

Key
/f - remove all network printer connections
/c - connect to \\PrintServer\PrintShare
/cd - connect to and set PrintShare as the default printer

It is part of the ZAK from WindowsNT, but it works sweet with XP and even Vista...

Demon10000
10-16-2007, 12:18 PM
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

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

For Each objPrinter in colInstalledPrinters

Select Case objPrinter.name
Case "PrinterNameToDelete"
objPrinter.Delete_
Case Esle
End Select
Next


That will delete a network printer called "PrinterNameToDelete" on any machine it's run on. If you want to delete the printer on a remote machine, change the line


strComputer = "."


to


strComputer = "ComputerToDeletePrinterFrom"


So, you'll need to change the name of the computer and the name of the printer, and you should be good to go!

QwertyJuan
10-16-2007, 12:58 PM
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

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

For Each objPrinter in colInstalledPrinters

Select Case objPrinter.name
Case "PrinterNameToDelete"
objPrinter.Delete_
Case Esle
End Select
Next


That will delete a network printer called "PrinterNameToDelete" on any machine it's run on. If you want to delete the printer on a remote machine, change the line


strComputer = "."


to


strComputer = "ComputerToDeletePrinterFrom"


So, you'll need to change the name of the computer and the name of the printer, and you should be good to go!

And this way requires you to change the name of the computer each time? If so, I hardly think it is even as close to as easy as using con2prt.... I use it in my logon script each time my clients login regardless.... deletes all their printers and reconnects them... takes a matter of seconds, and the user ONLY has the printers that are currently available.

Demon10000
10-16-2007, 01:47 PM
And this way requires you to change the name of the computer each time? If so, I hardly think it is even as close to as easy as using con2prt.... I use it in my logon script each time my clients login regardless.... deletes all their printers and reconnects them... takes a matter of seconds, and the user ONLY has the printers that are currently available.


With a half dozen more lines of code, he could have it run on every computer in the domain and remove it.

Could also modify it to run with group policy...

The point is, no one solution will work for everyone. I simply offered an alternate choice -- I wasn't trying to compete. :)

QwertyJuan
10-16-2007, 01:49 PM
With a half dozen more lines of code, he could have it run on every computer in the domain and remove it.

Could also modify it to run with group policy...

The point is, no one solution will work for everyone. I simply offered an alternate choice -- I wasn't trying to compete. :)

I thought you meant he would have to code each computer name into the script that he wanted to remove the printer from(maybe you do)..... to me that would be some mega hassle if you had anymore than 2 or 3 machines.... imagine having to do that for 200 or 300 machines? :)

Just thought it sounded like a lot of work is all.

Peace bro! :cool: