littleclown Posted September 20, 2006 Posted September 20, 2006 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.
dabus Posted September 20, 2006 Posted September 20, 2006 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)
littleclown Posted September 21, 2006 Author Posted September 21, 2006 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.
Bubnoff Posted October 7, 2006 Posted October 7, 2006 littleclown said: Hello! Can anybody help me? 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]
Bubnoff Posted October 7, 2006 Posted October 7, 2006 littleclown said: Hello! Can anybody help me? Try this post as well.http://www.autoitscript.com/forum/index.ph...c=29127&hl=Bubnoff [quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]
MadBoy Posted October 7, 2006 Posted October 7, 2006 Bubnoff said: 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@BubnoffDon'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)
MadBoy Posted October 7, 2006 Posted October 7, 2006 (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 October 7, 2006 by MadBoy My little company: Evotec (PL version: Evotec)
MadBoy Posted October 7, 2006 Posted October 7, 2006 (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() NextAnd i guess this code is better for this particular problem of yours Edited October 7, 2006 by MadBoy My little company: Evotec (PL version: Evotec)
Bubnoff Posted October 10, 2006 Posted October 10, 2006 MadBoy said: @BubnoffDon'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,@MadBoyYou'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]
littleclown Posted December 6, 2006 Author Posted December 6, 2006 Sorry for my biiiiiig pause. Now I will try all of your solutions and will say what happens. Thanx .
littleclown Posted December 6, 2006 Author Posted December 6, 2006 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.
Bert Posted December 6, 2006 Posted December 6, 2006 (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 December 6, 2006 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/
littleclown Posted December 6, 2006 Author Posted December 6, 2006 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
littleclown Posted December 8, 2006 Author Posted December 8, 2006 Anybody? The MadBoy's example is too close to my needs, but I can't run it correctly.
MadBoy Posted December 8, 2006 Posted December 8, 2006 littleclown said: 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)
littleclown Posted December 8, 2006 Author Posted December 8, 2006 (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 December 8, 2006 by littleclown
MadBoy Posted December 8, 2006 Posted December 8, 2006 Last time when i did conversion the script worked just fine. Now it doesn't 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)
littleclown Posted December 8, 2006 Author Posted December 8, 2006 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 .
MadBoy Posted December 8, 2006 Posted December 8, 2006 littleclown said: 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 only2. 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now