Scripting delete printers

G

Guest

Is there a way to delete printers using VBScript, JScript or WSH? If so, can
you point me to some documentation and or example.

Running Citrix MetaFrame with Terminal services on Windows 2000 Server, and
we have a lot of printing issues where printers are not being deleted. The
issue happens whether a user uses Citrix MetaFrame via the ICA client or
using Remote desktop to connect directly to terminal services.

Would like to write a script to delete the users printers on startup and or
shutdown.

Don Jones
 
G

Guest

Hey Don,

Here is a VB script using WMI to delete printers by Driver name. Taking a
quick look at the WIN32_Printer MOF you could replace DriverName with
Location, InstallDate, ShareName, ect.. There is a bunch you can sort on to
get the result you want, then just use the delete function to remove the
printer. I am not sure how good you are wiht WMI, but its pretty easy to
learn and there are plenty of resources out on technet..

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

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where DriverName = 'HP LaserJet'")

For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top