• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Help me with a script to purge print queue then delete

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
dirkdigs
Asked:
dirkdigs
  • 2
1 Solution
 
bluntTonyCommented:
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
 
dirkdigsAuthor Commented:
no i have that i just was posting the code that i think is wrong.
0
 
bluntTonyCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now