Solved

Help me with a script to purge print queue then delete

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 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

12 Experts available now in Live!

Get 1:1 Help Now