• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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
0
mcmoser
Asked:
mcmoser
1 Solution
 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now