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?
 
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
0
 
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.