Sunday, April 1, 2007

Print Queue Logging

Option Explicit

Dim PrintJobSet, fso, WriteLogFile

On Error Resume Next
Set PrintJobSet = GetObject("winmgmts:").InstancesOf("Win32_PrintJob")
Set fso = CreateObject("Scripting.FileSystemObject")
Set WriteLogFile = fso.OpenTextFile("C:\PrintJobLog.txt", 8)
If Err <> 0 Then
WriteLogFile.Write "Test Admin Print Queues Failed " & Err.Description & " " & Err.Number & " " & Now & vbNewLine
ElseIf Err = 0 Then
WriteLogFile.Write "Test Admin Print Queues Passed " & Now & vbNewLine
If (PrintJobSet.Count = 0) Then
WriteLogFile.Write "No print jobs!" & vbNewLine
Else
WriteLogFile.Write "Number of Jobs are " & PrintJobSet.Count & vbNewLine
End If

For Each PrintJob In PrintJobSet
WriteLogFile.Write "Name" & vbTab & "JobId" & vbTab & "Status" & vbTab & "TotalPages " & vbNewLine
WriteLogFile.Write PrintJob.Name & vbTab & PrintJob.JobId & vbTab & PrintJob.Status & vbTab & PrintJob.TotalPages & vbNewLine
Next
End If

Related Titles

 
visitors since March 26 2007
©2007