Solved

Help me with a script to purge print queue then delete

Posted on 2009-04-02
3
226 Views
Last Modified: 2012-06-21
whats wrong with this code? can someone help.
'call.2.purge.the.queue.then.delete
For Each objPrinter in colPrinters
    objPrinter.CancelAllJobs()
	objPrinter.Delete_
Next

Open in new window

0
Comment
Question by:dirkdigs
  • 2
3 Comments
 
LVL 27

Expert Comment

by:bluntTony
ID: 24052228
Aren't you missing the WMI query?
The below is the full version of what you have posted. Bear in mind that this will purge and delete EVERY printer found on the local machine.

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer")
 
For Each objPrinter in colInstalledPrinters
    objPrinter.CancelAllJobs()
	objPrinter.Delete_
Next

Open in new window

0
 

Author Comment

by:dirkdigs
ID: 24054490
no i have that i just was posting the code that i think is wrong.
0
 
LVL 27

Accepted Solution

by:
bluntTony earned 500 total points
ID: 24057984
Unfortunately that doesn't really show us much. Could you post the WMI query you have used, and the error message you are getting, and on what line this is occurring?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question