Removing printer from Remote PC

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
mcmoserAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EDDYKTCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcmoserAuthor 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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.