Home | Download | Demo | Feature list | Premium users | Support | Knowledgebase
How to fix WMI Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
The network path was not found - The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
How to configure Windows Vista clients.
How to configure the windows firewall using group policies.
   
Welcome Guest Search | Active Topics | Members | Log In | Register

Show Print Jobs older than 15 minutes Options
ejensen
Posted: Tuesday, May 06, 2008 10:39:40 PM
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

BullGates
Posted: Wednesday, May 07, 2008 12:21:22 AM

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...
ejensen
Posted: Wednesday, May 07, 2008 12:33:26 PM
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
BullGates
Posted: Wednesday, December 03, 2008 7:10:40 PM

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!
BullGates
Posted: Wednesday, December 03, 2008 7:17:21 PM

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 ;-)
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.

   
Quick links: Download - Premium users - Support 
Copyright 2004 - 2008 © Geert Moernaut - Hemoco bvba - All rights reserved