Solved

Help me with a script to purge print queue then delete

Posted on 2009-04-02
3
224 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now