Remove Printer Installed as a Device VBScript

Brent387 used Ask the Experts™

I have attached a script below which I don't think will work when deployed and I also don't think that it's the best method for doing this:

A colleague installed a printer in our remote office as a device and not a printer. We'd like to use a script to remove this device/printer but the standard remove printer script that I had isn't working on it. Our users run Windows 7 x64.

Can anyone offer any suggestions on the existing script or offer a better solution to do this?

Thank you
strComputer = "."
strQuery="Select * from Win32_PNPSignedDriver"

Set objWMIService=GetObject("winmgmts:" _
	& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\CIMV2")

Set ColDevice=objWMIService.ExecQuery(strQuery) 
For Each objDevice in ColDevice

If strDev=("XRX0000AAD33FF2") Then

End if

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can use DevCon utility to add/remove devices remotely:

If you get thehardware ID, you can remove it with this command:

devcon /r remove "PCI\VEN_8086&DEV_7110"
You would use a command remotely, like:

devcon -m:computername remove "PCI\VEN_8086&DEV_7110"

Just change the PCI\VEN_8086&DEV_7110 to the hardware ID of the printer

Here's another script to try

strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\roo\cimv2") 
Set colInstalledPrinters =  objWMIService.ExecQuery _ 
    ("Select * from Win32_Printer where DeviceID = 'Printer1'") 
For Each objPrinter in colInstalledPrinters 

Open in new window

Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.


That script did not work. I think it needs to look for devices and not printers. Would I have to install the DevCon utility on all the remote computers?
No, you can run devcon against a remote computer...using my second post as a guide.


Devcon does not install. It says that each version is incompatible with my OS. I have Win7x64
Apparently, there is an updated version in this package:

I will extract it from the ISO and see if I can upload it here.

Or, you can just use devcon from any x86 computer.  I use it on my Win7x86 laptop.
Try this version of devcon
Fyi for anyone interested, if you download the ISO, the devcon utility is in the WDM\setuptools_x64fre.msi package.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial