We help IT Professionals succeed at work.

How to automatiocally remove a printer with a batch program, that is installed with an IP address as a port.

We are replacing a large copy machine at our company that can act as a color printer as well.  It is our intention to remove the color printers and replace them wit the new color copiers.

I know how to add a printer in a batch program ... START "" "\\server\LargeCopy_Room"

my question is how can I use a batch file or command to delete a locally installed printer that is added via IP address?

 addes by IP port
Or  must I just go to every PC that might have the printer and manually delete it?  Again, these already existing color printers are not installed on a printer server, they have installed manually on the PC's via IP address.
Watch Question

Neil RussellTechnical Development Lead

there are a pile of vb scripts that were shipped with windows 2000 onwards for all kinds of management, printers being one.

Cscript Prnmngr.vbs -d -p yourprintername

Should do the trick.
Scripts are normally found in  
Kent WSr. Network / Systems Admin

Do a "net use" and see how your printer is listed.
You may get something like

Status     Local    Remote              Network
OK           LPT2    \\xerox\printer

You can use, for instance
to map the printer, and add /DELETE to the end of your command to remove it
Kamaraj SubramanianApplication Support Analyst
Try this vbscript.

This will delete the printers, which is attached in the local machine

strComputer = "."  
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")   
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer",,48)  
For Each objPrinter in colItems  

Open in new window

Neil RussellTechnical Development Lead

My post above should have been

Cscript Prnmngr.vbs -dl -p yourprintername
erobbySenior Systems Engineer

This should help

rundll32 printui.dll,PrintUIEntry /dl /n "C5815 PCL5c"
Senior Systems Engineer
oops typo

rundll32 printui.dll,PrintUIEntry /dl /n "C5185 PCL5c"
PkafkasNetwork Engineer


erobby: your statement worked.  rundll32 printui.dll,PrintUIEntry /dl /n "C5185 PCL5c"

Neilsr: your statement did not work for me becasue I didn ot have the 'Prnmngr.vbs' on my pc.

mugojava: Your comment did nto help me because this printer was using an IP address not a LPT-port.

C:\>net use lpt2
System error 2 has occurred.

The system cannot find the file specified.

C:\>net use
System error 67 has occurred.

The network name cannot be found.

PkafkasNetwork Engineer


itkamaraj: I did not try your program because I do not have a vbscript compiler on my pc.
Kent WSr. Network / Systems Admin

You had a couple of things missing trying the NET USE example, so just wanted to make you aware.
The complete command was not tried, you would also have to give the full UNC path, not just the IP ;)  so NET USE won't work, obviously, it would need to be something like NET USE LTPx \\\sharename.  

I didn't see the delete switch on the example that didn't work for you, so not sure if you would want to write that off quickly, it may still work. LTP2 was an example, I have no idea what or if you are using LTP over IP (which is common if the printer itself has an IP address, and can be set up that way even it it's not currently, so the simple command can work)

On a computer currently connected to the printer in question, do a
and look at the output.  

If the printer is listed, note the LOCAL and REMOTE field names in the output.
If it is, you CAN delete it by giving (substitute the actual values in LOCAL and REMOTE)


Remember, the REMOTE field will be a UNC, and will start with \\
To connect it again, just don't give the /DELETE switch, you may or may not have to give the REMOTE, depending on how the printer is setup locally

To connect, you would use either
NET USE LOCAL \\REMOTE with an optional /persistent:yes if you want it to persist over reboots.

substitute the entry under the LOCAL and REMOTE fields from the first NET USE command.