We help IT Professionals succeed at work.

Removing printer with a login script

yanbergeron24
on
Medium Priority
620 Views
Last Modified: 2012-05-05
Hi,

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???

Thanks,

Yan Bergeron
Montréal
Comment
Watch Question

Try:

    net.RemovePrinterConnection ".\printername"

or maybe:

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

J.

Author

Commented:
Hi,

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?

Commented:
Here is an example that uses Prnadmin.dll from the resource kit:

http://thelazyadmin.com/index.php?/archives/159-Manage-Printers-With-VBS,-WMI-and-Prnadmin.dll.html
yanbergeron24,

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))
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.