Announcement

Collapse
No announcement yet.

Create a script to remove a network printer from a user's account

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create a script to remove a network printer from a user's account

    Hi Everyone,

    How can I create a script (.bat) file to delete a specific network printer?

    Normally we add printers with the start command, for example:
    start \\servername\printer1
    start \\servername\printer2

    If I want to delete "printer1" from the user's list of available network printers, what command should I use? I've been seeing some articles out there on "rundll32 printui.dll", but I'd rather use the simplest method... sorry, I'm a noob at this, but is it possible to use: start \\servername\printer1 /del (or something similar)?

    Thanks in advance for the help!

  • #2
    Re: Create a script to remove a network printer from a user's account

    I think you're missing something here because it doesn't silently install... start \\servername\printer1
    unless you want it to prompt the user to install.

    you can't use /del [/d] to remove a printer unless it's added like this...
    start net use lpt1: \\servername\printer1
    then you could remove it using...
    start net use lpt1: /d

    network printers that aren't using an lpt port can't be removed that way, which is why it was suggested that you use "rundll printui.dll".

    remove network printer
    rundll32 printui.dll,PrintUIEntry /gn /c\\targetmachine /n\\server\printershare
    Last edited by ahinson; 14th April 2009, 14:53.
    Andrew

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    Comment


    • #3
      Re: Create a script to remove a network printer from a user's account

      Just a few batch-code samples
      (note: "PrintUIEntry" is case sensitive!)

      Code:
      :: Add networkprinter connection (using sharename)
      @Rundll32.exe printui.dll,PrintUIEntry /in /q /n"\\server\printersharename"
      
      pause
      
      :: Delete networkprinter connection (using sharename)
      @Rundll32.exe printui.dll,PrintUIEntry /dn /q /n"\\server\printersharename"
      
      pause
      
      :: Add networkprinter connection (using printer name) (winxp/2k3)
      @Cscript.exe //nologo //b "%windir%\system32\Prnmngr.vbs" -ac -p "\\server\printer name"
      
      pause
      
      :: Delete networkprinter connection (using printer name) (winxp/2k3)
      @Cscript.exe //nologo //b "%windir%\system32\Prnmngr.vbs" -d -p "\\server\printer name"
      Last edited by Rems; 14th April 2009, 15:27.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment

      Working...
      X