Removing printer with a login script

Posted on 2006-04-05
Last Modified: 2012-05-05

I would like to know if it is possible to delete a local printer on Windows XP with a login script.

I know it is possible to delete a network printer with this VBscript

Dim net
Set net = CreateObject("WScript.Network")
net.RemovePrinterConnection "\\bonemine\020-labo-01"

But what about local printers???


Yan Bergeron
Question by:yanbergeron24
    LVL 16

    Expert Comment


        net.RemovePrinterConnection ".\printername"

    or maybe:

        net.RemovePrinterConnection "\\" & net.ComputerName & "\printername"


    Author Comment


    net.RemovePrinterConnection ".\HP 2000C"
          doesn't work. Error (this connection doesn't exist)

    net.RemovePrinterConnection "\\" & net.ComputerName & "\HP 2000C"
          doesn't work. Error (this connection doesn't exist)

    More idea?
    LVL 28

    Expert Comment

    Here is an example that uses Prnadmin.dll from the resource kit:,-WMI-and-Prnadmin.dll.html
    LVL 6

    Expert Comment


    Not sure about this, but ......
    When you use net.RemovePrinterConnection, don't worry about the machine name qualifier if its a local printer.
    Try    net.RemovePrinterConnection "020-labo-01"

    Alternatively :-)   The command below will install a printer instance.  I'm sure there's something similiar to remove one.

        Shell ("rundll32 printui.dll,PrintUIEntry /if /u /b " & Chr$(34) & FullPrinterDriverName & Chr$(34) & " /m " & Chr$(34) & FullPrinterDriverName & Chr$(34) & " /f " & Chr$(34) & PrinterDriverINF & Chr$(34) & " /r " & Chr$(34) & PrinterPort & Chr$(34))
    LVL 4

    Accepted Solution

    delete them from registry with visual basic

    HK current user / printers
    search for the printer, and delete the key.

    you can make an exe and put it in to the login script

    also, maybe you are tired of xp automatic printer discovery, on explorer select TOOLS / OPTIONS
    [ VIEW ]
    [_] search for network printer / folders (something like that, i dont have an xp english version near)

    hope this helps
    LVL 4

    Expert Comment

    thanks yanbergeron24

    note that this procedure will left drivers and everything still on the disk.  wich can be cluttering if this is one of those printers that need special apps to make it work.


    but if it is some "xp detected and automatically installed printer" i think there is no big trouble.

    Thanks again.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now