We help IT Professionals succeed at work.

Removing printer from Remote PC

mcmoser
mcmoser asked
on
Medium Priority
210 Views
Last Modified: 2010-04-07
Hello,

Thanks to another user here, i'm now able to get a listing of the printers installed on a remote pc by using:

    Set objLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objWMIService = objLocator.ConnectServer(RemoteComputer, "root\cimv2", RemoteUsername, RemotePassword)
    objWMIService.Security_.impersonationLevel = 3
    Set PrinterList = objWMIService.ExecQuery("Select * from Win32_Printer")
    For Each PrinterInstance In PrinterList
        lstPrinters.AddItem PrinterInstance.Name
    Next
    Set PrinterList = Nothing
    Set WMIService = Nothing


Now I would like to be able to remove a printer from that that workstation. Is it possible? As it is, I can use a dos command to accomplish what I want, but I would like to skip it if possible.

Thanks
Comment
Watch Question

Commented:
Does this one help? Have not tried by myself


http://www.experts-exchange.com/Programming/Q_21352187.html

i.e

Set Net = CreateObject("WScript.Network")

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objWMIService = objLocator.ConnectServer(RemoteComputer, "root\cimv2", RemoteUsername, RemotePassword)
    objWMIService.Security_.impersonationLevel = 3
    Set PrinterList = objWMIService.ExecQuery("Select * from Win32_Printer")
    For Each PrinterInstance In PrinterList
        lstPrinters.AddItem PrinterInstance.Name
        Printer = PrinterInstance.Name
        Net.RemovePrinterConnection Printer
    Next
    Set PrinterList = Nothing
    Set WMIService = Nothing

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

Ask the Experts

Author

Commented:
Hi,
I get network connection does not exist when i use that @

Net.RemovePrinterConnection printer


This looks to be a hard thing to do.
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.