Sign in to follow this  
Followers 0
littleclown

Delete all printer jobs

33 posts in this topic

Hello. This is my first post here, and first of all excuse me, for my English. Can I use AutoIT! for deleting all print jobs? I have 10 network printers, but one of them every morning printing some shits, and i must delete all jobs manualy.

Share this post


Link to post
Share on other sites



Stop the printerqueue-service (Run ('net stop XXX') or sc can do this)

Search @systemdir&'\spool\PRINTERS' and delete the files (FileFindFirstFile + FileDelete)

Start the queue (Run ('net start XXX') or sc)

Share this post


Link to post
Share on other sites

Hm. Is this correct for jobs from other computers in the network. I mean my PC is not a print server and the jobs are not from me. I make new jobs from other PC, but my spooler directory is not changed - the file is one - SPL3D9.tmp - 64kb.

Share this post


Link to post
Share on other sites

Hello! Can anybody help me? :)

Share this post


Link to post
Share on other sites

Hello! Can anybody help me? :lmao:

Littleclown:

The answer is no. You won't find anyone on this forum. Everyone (the Gurus, that is) is far too preoccupied with helping teens make bots for online games or inadvertantly aiding teens creating viruses etc...

How do I know this. I have a similar problem to yours and have received few responses since posting.

Here is a site for .vbs scripts that will do what you need, with a bit of tweaking.

http://www.activexperts.com/activmonitor/w...inting/servers/

This was the lone piece of advice I've received since posting (thanks Strate). You could try translating this into Autoit,

but its likely to be more of a hassle than its worth. In defense of the forum, I will say that this may be one of those things that Autoit is less adept at (judging from the responses to similar posts).

Good luck ....

Bubnoff


[quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]

Share this post


Link to post
Share on other sites

Littleclown:

The answer is no. You won't find anyone on this forum. Everyone (the Gurus, that is) is far too preoccupied with helping teens make bots for online games or inadvertantly aiding teens creating viruses etc...

How do I know this. I have a similar problem to yours and have received few responses since posting.

Here is a site for .vbs scripts that will do what you need, with a bit of tweaking.

http://www.activexperts.com/activmonitor/w...inting/servers/

This was the lone piece of advice I've received since posting (thanks Strate). You could try translating this into Autoit,

but its likely to be more of a hassle than its worth. In defense of the forum, I will say that this may be one of those things that Autoit is less adept at (judging from the responses to similar posts).

Good luck ....

Bubnoff

@Bubnoff

Don't judge AutoIt forum and it's users by problem you didn't get help on. Ppl here are good and very helpefull but only if they KNOW how to solve something. Sometimes the problem is more complicated and maybe very few ppl know the answer. And next few that possibly could solve this by sitting on this problem for few hours never had problem like that so don't punish them for not sitting on your problem. It's still your problem not theirs. As far as i can see ppl that actually know what might be problem or know the solution post it. Maybe when you're done with code to achieve this post it here so ppl will know how to solve this problem in AutoIt.

One more thing. Before you start blaming ppl for not helping you out, make sure you wouldn't act exactly the same when you wouldn't be sure what the answer is. I hope that in half year you will have 1000 posts and all in Support forum with you helping out others. Then you will see how easy it is to help ppl. It's not fulltime job, it's a hobby for most ppl to HELP you. So enjoy your stay and be glad the forum is active as it's one of the best forums you will ever see.

Cheers,


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

And actually. WMI in AutoIt is very similar to it's orginal version

Orginal:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob Where Size > 1000000")
For Each objPrintJob in colPrintJobs 
    objPrintJob.Delete_
Next

AutoIt one:

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colPrintJobs =  $objWMIService.ExecQuery ("Select * from Win32_PrintJob Where Size > 1")
For $objPrintJob in $colPrintJobs 
    $objPrintJob.Delete_
Next

Think it works, i just tested it locally on my computer. Hope you get the idea. Rest is very similar. Get Scriptomatic from Scripts and Scraps for WMI calls and you can easly compare them

Edit: typos in code

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Another conversion:

Purging a Print Queue

Deletes all the print jobs for a printer named HP QuietJet.

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

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\" & $strComputer & " ootcimv2")
$colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer Where Name = 'HP LaserJet 3200 Series PCL'")
For $objPrinter in $colInstalledPrinters
    $objPrinter.CancelAllJobs()
Next

And i guess this code is better for this particular problem of yours :lmao:

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

@Bubnoff

Don't judge AutoIt forum and it's users by problem you didn't get help on. Ppl here are good and very helpefull but only if they KNOW how to solve something. Sometimes the problem is more complicated and maybe very few ppl know the answer. And next few that possibly could solve this by sitting on this problem for few hours never had problem like that so don't punish them for not sitting on your problem. It's still your problem not theirs. As far as i can see ppl that actually know what might be problem or know the solution post it. Maybe when you're done with code to achieve this post it here so ppl will know how to solve this problem in AutoIt.

One more thing. Before you start blaming ppl for not helping you out, make sure you wouldn't act exactly the same when you wouldn't be sure what the answer is. I hope that in half year you will have 1000 posts and all in Support forum with you helping out others. Then you will see how easy it is to help ppl. It's not fulltime job, it's a hobby for most ppl to HELP you. So enjoy your stay and be glad the forum is active as it's one of the best forums you will ever see.

Cheers,

@MadBoy

You're absolutely right! I totally jumped the gun on this one. There is actually alot more help with Printer-related problems on this forum than I realized (as a quick search under "Printer" pointed out). There is definately alot more than there was 2 weeks ago.

My apologies to the "Gurus".

I officially retract my previous comments posted above....

Long Live Autoit!!!!

Bubnoff


[quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]

Share this post


Link to post
Share on other sites

Sorry for my biiiiiig pause. Now I will try all of your solutions and will say what happens.

Thanx ;).

Share this post


Link to post
Share on other sites

The single example of madboy working fine, but when I try to select a single printer by name nothing happen:

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colPrintJobs =  $objWMIService.ExecQuery ("Select * from Win32_PrintJob Where name = 'SOF11PRT12ALC_1'")
$test = $objWMIService.ExecQuery ("Select * from Win32_PrintJob Where Name = 'SOF11PRT12ALC_1'")
MsgBox(0,0,$test)
For $objPrintJob in $colPrintJobs
    $objPrintJob.Delete_
Next

The second one dont work:

Variable must be of type "Object".

I tried diferent combinations of this two script but I can't delete the jobs from my printer.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I have a script that will do the job quite easily, and it has been in production for several months now. Try this, and see if this will work for you:

#include <Process.au3>
SplashTextOn("", "Stopping Print Spooler, please wait...", 150, 75)
_RunDOS("NET STOP spooler")
SplashOff()
SplashTextOn("", "Clearing stuck print jobs, please wait...", 150, 75)
sleep(2000)
FileDelete(@SystemDir & "\spool\PRINTERS\*.*")
SplashOff()
SplashTextOn("", "Starting Print Spooler, please wait...", 150, 75)
_RunDOS("NET START spooler")
SplashOff()
MsgBox(64, "Done!", "Done", 3)

You can PM me if you have any issues with it. Hope this helps

Edited by Volly

Share this post


Link to post
Share on other sites

I don't have permission for PM.

My problem is that my PC is not the Printer server. This printer is network, I have permission to delete jobs, but not permission to delete files.

Thats why I need to use some other kind of manipulation to clean jobs.

MadBoy gave me a clue, but don't work, and the code is too hard to debug it to myself.

If you have rights to write PM-s, please send him this post

10x ;)

Share this post


Link to post
Share on other sites

Anybody? The MadBoy's example is too close to my needs, but I can't run it correctly.

Share this post


Link to post
Share on other sites

Anybody? The MadBoy's example is too close to my needs, but I can't run it correctly.

Okej, i see where you have your problem. You get error about Object when the printer doesn't exist ;) It works just fine when the printer name is correct. So check for that. Also notice $strComputer = "localhost". Means it will only work when you start this script locally. So if you typed in printer name from server and haven't changed $strComputer to server name it wouldn't work (aka you would get an error about missing Object). Also you have to have some rights on server to use that script thru network. Make sure you have them. Hope this will help you.

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
$colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer Where Name = 'HP LaserJet 3200 Series PCL'")
For $objPrinter in $colInstalledPrinters
    $objPrinter.CancelAllJobs()
Next

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Maybe I don't have permittion, but this script:

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colPrintJobs =  $objWMIService.ExecQuery ("Select * from Win32_PrintJob Where Size > 1")
For $objPrintJob in $colPrintJobs
    $objPrintJob.Delete_
Next

Works perfect and my print server is not the PC where I start this script (but i use "localhost" for $strComputer).

I just wont to del jobs form specify printer, not *. When I try to use Name (i believe this is the comumn of printer names) nothing happen - no error, no action.

Maybe some problem with brackets or something like this...?

Edited by littleclown

Share this post


Link to post
Share on other sites

Last time when i did conversion the script worked just fine. Now it doesn't :lmao: Dunno why

As workaround for now use this code within .vbs file ;)) works

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

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Hm. You see I am a newbie in Auto IT and programming at all, and thats why please help me how to use vbs files in my scripts (i search in forum, but nothing found).

You have 2 beers if you go to Bulgaria ;).

Share this post


Link to post
Share on other sites

Hm. You see I am a newbie in Auto IT and programming at all, and thats why please help me how to use vbs files in my scripts (i search in forum, but nothing found).

You have 2 beers if you go to Bulgaria ;) .

Well you can do 2 things:

1. Create .vbs file and just put the code in and use that only

2. If you want to use AutoIt for it and have other things done aswell you can do step 1 and then in .au3 file put

RunWait("script.vbs") and it will execute the .vbs script (can be full path or anything) to run that script fromwithin AutoIt. You could also FileInstall (check help for that) it if you want to compile .au3 to exe later on.


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0