Solved

Help me with a script to purge print queue then delete

Posted on 2009-04-02
3
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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