[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Removing printer with a login script

Posted on 2006-04-05
6
Medium Priority
?
600 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
0
Comment
Question by:yanbergeron24
6 Comments
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 16384511
Try:

    net.RemovePrinterConnection ".\printername"

or maybe:

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

J.
0
 

Author Comment

by:yanbergeron24
ID: 16386057
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?
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 16386481
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:DeadlyTrev
ID: 16388272
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))
0
 
LVL 4

Accepted Solution

by:
HTorres earned 2000 total points
ID: 16532325
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
0
 
LVL 4

Expert Comment

by:HTorres
ID: 16534739
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

834 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