Delete network printer from a remote pc

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jreat
Posts: 7
Joined: 09 Sep 2009 14:32

Delete network printer from a remote pc

#1 Post by jreat » 20 Aug 2010 11:49

I am trying to make a script that will delete a printer from a pc. For example I am on pc 1234 and want to run this program that will ask me for the pc i want to delete the printer from and what printer it is. So pc 789 i want to delete printer123 on printerserver

I have the following so far but it does not work :( Any help would be appreciated. Thank You

@echo off
:start
@echo This will delete network printers from a remote pc
@echo.
@echo Please type in the Asset Tag of the device to delete from
set /p tag=
@echo Please type in the Printer Name that you would like to delete
set /p printer=
rundll32 printui.dll,PrintUIEntry /dn /c\\%tag% /n\\dvmsprn04\%printer%
@echo.
@echo Delete another (y/n)?
set /p another=
if '%another%'=='y' goto start
if '%another%'=='n' goto end
:end
exit

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Delete network printer from a remote pc

#2 Post by aGerman » 20 Aug 2010 16:28

Hmm. Looks right for me. If you run
rundll32 printui.dll,PrintUIEntry /?
you will find the same syntax like yours. But the M$ support shows an opposite style for /c and /n options:
The following example deletes an Agfa printer on a computer named SERVER:

Code: Select all

rundll32 printui.dll,PrintUIEntry /dl /n "Test Printer" /c\\SERVER


No idea if this makes a difference.
Did you try to run as admin?
Or maybe it's not available on your OS. Did rundll32 printui.dll,PrintUIEntry /? work for you?

Regards
aGerman

Post Reply