|
|
Rank: Freeware Member Groups: Member
Joined: 5/2/2008 Posts: 26 Location: Ohio, USA
|
this one will run script against a computer and show any printer queues with jobs older than 15 minutes. Action: Code:cmd.exe /K cscript \\SERVER\SHARE\show_print_queues_time.vbs {computer} VBscript file: Code:Const USE_LOCAL_TIME = True Set DateTime = CreateObject("WbemScripting.SWbemDateTime") strComputer = Wscript.Arguments.Item(0) Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_PrintJob") Wscript.Echo "Print Queue" & vbTab & "Job ID" & vbTab & "Submitted" & vbTab & "Total Pages" For Each objPrinter in colInstalledPrinters DateTime.Value = objPrinter.TimeSubmitted dtmActualTime = DateTime.GetVarDate(USE_LOCAL_TIME) TimeinQueue = DateDiff("n", actualTime, Now) If TimeinQueue > 15 Then strPrinterName = Split(objPrinter.Name,",",-1,1) Wscript.Echo strPrinterName(0) & vbtab & vbTab & objPrinter.JobID & vbTab & dtmActualTime & vbTab & objPrinter.TotalPages End If Next
|
|
 Rank: Premium user Groups: Member
, Premium Users
Joined: 9/29/2007 Posts: 44 Location: PT
|
Nice! You seem to have some nice ideas, I was thinking about something similar and I wanted something a step further... I need something to erase older than X time jobs from the print server, because sometimes users send print jobs to offline printers and when they turn them on, they get the old jobs printed. Until now I had no time to investigate further, there are some utilities that seem to help on that but...
|
|
Rank: Freeware Member Groups: Member
Joined: 5/2/2008 Posts: 26 Location: Ohio, USA
|
I do have a script to do that, but you have to specify the printer name. Not sure how to tie this into LS yet... working on my first cup of coffee still. :) Would probably need to be tied into an HTA that can read all the print queues on a server name that is passed as a variable from LS. I will see what i can put together today if I have some time. Here is the vbscript code: Code: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
|
|
 Rank: Premium user Groups: Member
, Premium Users
Joined: 9/29/2007 Posts: 44 Location: PT
|
Hello! Just sharing the code, finally I could do this although the code may not look great, it works! ;-) Just change PrintServerName with your Windows print server. Adjust the TimeinQueue to fit your needs and it will keep the queue jobs clean if you schedule it on the server. Code:Const USE_LOCAL_TIME = True Set DateTime = CreateObject("WbemScripting.SWbemDateTime") strComputer = "PrintServerName" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_PrintJob") Wscript.Echo "Print Queue" & vbTab & "Job ID" & vbTab & "Submitted" & vbTab & "Total Pages" For Each objPrinter in colInstalledPrinters DateTime.Value = objPrinter.TimeSubmitted dtmActualTime = DateTime.GetVarDate(USE_LOCAL_TIME) TimeinQueue = DateDiff("n", dtmactualTime, Now) If TimeinQueue > 1440 Then strPrinterName = Split(objPrinter.Name,",",-1,1) Wscript.Echo strPrinterName(0) & vbtab & vbTab & objPrinter.JobID & vbTab & dtmActualTime & vbTab & objPrinter.TotalPages Set objWMIService1 = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters1 = objWMIService.ExecQuery _ ("Select * from Win32_Printer Where Name = '" & strPrinterName(0) & "'") For Each objPrinter1 in colInstalledPrinters1 objPrinter1.CancelAllJobs() Next End If Next Thank you for the sample code ejersen!
|
|
 Rank: Premium user Groups: Member
, Premium Users
Joined: 9/29/2007 Posts: 44 Location: PT
|
oops, better thinking this erases all the queue jobs! I will have to recheck the code ;-)
|
|
|
Guest |