Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Print Queue Status 2

Status
Not open for further replies.

jimmYLepp

Programmer
Jan 22, 2002
39
US
Currently I have a server printing reports to an offsight location throughout the day. Right now I am stuck on trying to create a WBS script on NT 4.0 that will check how many jobs are in the print queue. I have found how to get info about everything for the printer but how many jobs are in it's queue

Thanks,

jimmY [pimp]
 
Here's a script I have to delete jobs from the print queue.
You'll have to modify it to meet your needs. The first oShell send the net print output to a file. I then open that and parse the data that I need.

I hope this helps!

Mapman04

VB Script Code

Dim oShell,fso,txt3,adm1,adm2,intJobs,intID,intCnt

Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /C CD C:\ & Net Print \\Computername\Printer >C:\Temp\Print.txt",0,true
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set txt3 =fso_OpenTextFile("C:\Temp\Print.txt",1)
intCnt = 0
Do While txt3.AtEndOfStream = False
adm1 = txt3.ReadLine
adm2 = Mid(adm1,33,2)
If IsNumeric(adm2) = True Then
intID = CInt(adm2)
oShell.run "cmd /C CD C:\ & Net Print \\Printer " & intID & " /Delete",0,true
intCnt = intCnt + 1
End If
Loop
txt3.Close
If intCnt>0 Then
oShell.Popup intCnt & " print jobs were deleted from the queue!",5,"Company",0
End If
WScript.Quit
 
That;s pretty slick, I wouldn't of thought of that

thanks for your help

jimmY [pimp]
 
i would go for something like

Set objPrintQ = GetObject("WinNT://" & strDomainName & "/" & strCompName & "/" strQName)
For Each aPrintJob In objPrintQ.PrintJobs
'do something
Next


you can use the above to return whatever you want, changing priorities on print jobs, pausing print qs, etc etc etc
 
My file looks pretty much like the example given, but i have been asked to delete the temporary file created to store the output of "net print" printer queue output. My first response was to include "fso.DeleteFile printer.txt" (for the example given), but i get a response of "Permission Denied". Can anyone tell me how to force it to delete the file?
 
Make sure you close the file before you try to delete it. I added the fso.deletefile command to my script after I close it and it deletes it. If it's added before you close it, you get the permission error. Hope this helps.

Regards,

mapman04
 
To not create temporary file, you can play with the Exec method instead of the Run method, and the read the StdOut texstream:
Code:
Dim WshShell, oExecSet WshShell = CreateObject("WScript.Shell")
Set oExec    = WshShell.Exec("%comspec% /c dire")Function ReadAllFromAny(oExec)
     If Not oExec.StdOut.AtEndOfStream Then
          ReadAllFromAny = oExec.StdOut.ReadAll
Set oShell=WScript.CreateObject("WSCript.shell")
Set oExec=oShell.Exec("%COMSPEC% /C Net Print \\Computername\Printer")
Do While oExec.Status=0
  WScript.Sleep 100
Loop
intCnt=0
Do While Not oExec.StdOut.AtEndOfStream
  adm1=oExec.StdOut.ReadLine
  adm2=Mid(adm1,33,2)
  If IsNumeric(adm2) Then
    oShell.Run "%COMSPEC% /C Net Print \\Printer " & adm2 & " /Delete",0,true
    intCnt=intCnt+1
  End If
Loop

Hope This Help
PH.
 
OOPS; Clicked to quickly ...
To not create temporary file, you can play with the Exec method instead of the Run method, and the read the StdOut texstream:
Code:
Set oShell=WScript.CreateObject("WSCript.shell")
Set oExec=oShell.Exec("%COMSPEC% /C Net Print \\Computername\Printer")
Do While oExec.Status=0
  WScript.Sleep 100
Loop
intCnt=0
Do While Not oExec.StdOut.AtEndOfStream
  adm1=oExec.StdOut.ReadLine
  adm2=Mid(adm1,33,2)
  If IsNumeric(adm2) Then
    oShell.Run "%COMSPEC% /C Net Print \\Printer " & adm2 & " /Delete",0,true
    intCnt=intCnt+1
  End If
Loop

Hope This Help
PH.
 
Thanx guys,
now i am able to do it... thanx for all ur replies...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top