Win32_PrintJob class

The Win32_PrintJob WMI class represents a print job generated by a Windows application. Any unit of work generated by the print command of an application that is running on a computer running on a Windows operating system is a descendant or member of this class.

The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties are listed in alphabetic order, not MOF order.

Syntax

class Win32_PrintJob : CIM_Job
{
  string   Caption;
  string   Description;
  datetime InstallDate;
  string   Name;
  string   Status;
  datetime ElapsedTime;
  string   JobStatus;
  string   Notify;
  string   Owner;
  uint32   Priority;
  datetime StartTime;
  datetime TimeSubmitted;
  datetime UntilTime;
  string   Color;
  string   DataType;
  string   Document;
  string   DriverName;
  string   HostPrintQueue;
  uint32   JobId;
  uint32   PagesPrinted;
  uint32   PaperLength;
  string   PaperSize;
  uint32   PaperWidth;
  string   Parameters;
  string   PrintProcessor;
  uint32   Size;
  uint32   StatusMask;
  uint32   TotalPages;
};

Members

The Win32_PrintJob class has these types of members:

Methods

The Win32_PrintJob class has these methods.

Method Description
Pause Pauses a print job.
Resume Continues a print job.

 

Properties

The Win32_PrintJob class has these properties.

Caption

Data type: string

Access type: Read-only

Qualifiers: MaxLen (64), DisplayName ("Caption")

A short textual description of the object.

This property is inherited from CIM_ManagedSystemElement.

Color

Data type: string

Access type: Read-only

String that indicates whether the document is printed in color or monochrome. Some color printers have the capability to print using true black instead of a combination of yellow, cyan, and magenta. True black usually creates darker and sharper text for documents. This option is only useful for color printers that support true black printing.

The values are:

"Color"

"Monochrome"

DataType

Data type: string

Access type: Read-only

Format of the data for this print job. This instructs the printer driver to translate the data (generic text, PostScript, or PCL) before printing, or print in a raw format (for graphics and pictures).

Example: "TEXT"

Description

Data type: string

Access type: Read-only

Qualifiers: DisplayName ("Description")

A textual description of the object.

This property is inherited from CIM_ManagedSystemElement.

Document

Data type: string

Access type: Read-only

Name of the print job. The user sees this name when viewing documents that are waiting to be printed.

Example: "Microsoft Word - Review.doc"

DriverName

Data type: string

Access type: Read-only

Name of the printer driver used for the print job.

ElapsedTime

Data type: datetime

Access type: Read-only

Length of time the job has been executing.

This property is inherited from CIM_Job.

HostPrintQueue

Data type: string

Access type: Read-only

Name of the computer on which the print job is created.

InstallDate

Data type: datetime

Access type: Read-only

Qualifiers: MappingStrings ("MIF.DMTF|ComponentID|001.5"), DisplayName ("Install Date")

Indicates when the object was installed. Lack of a value does not indicate that the object is not installed.

This property is inherited from CIM_ManagedSystemElement.

JobId

Data type: uint32

Access type: Read-only

Identifier number of the job. It is used by other methods as a handle to a job spooling to the printer.

JobStatus

Data type: string

Access type: Read-only

Free-form string that represents the job status.

This property is inherited from CIM_Job.

Name

Data type: string

Access type: Read-only

Qualifiers: DisplayName ("Name")

Label by which the object is known. When subclassed, this property can be overridden to be a key property.

This property is inherited from CIM_ManagedSystemElement.

Notify

Data type: string

Access type: Read-only

User is notified upon job completion or failure.

This property is inherited from CIM_Job.

Owner

Data type: string

Access type: Read-only

User who submitted the job.

This property is inherited from CIM_Job.

PagesPrinted

Data type: uint32

Access type: Read-only

Number of pages that are printed. This value may be 0 (zero) if the print job does not contain page-delimiting information.

PaperLength

Data type: uint32

Access type: Read-only

Qualifiers: Units (Tenths of a millimeter.)

Length of the paper.

Example: 2794

PaperSize

Data type: string

Access type: Read-only

Size of the paper used to print the job. The value is one of the possible paper sizes for the printer specified in the PaperSizesSupported property of Win32_Printer class.

PaperWidth

Data type: uint32

Access type: Read-only

Qualifiers: Units (Tenths of a millimeter.)

Width of the paper.

Example: 2159

Parameters

Data type: string

Access type: Read-only

Optional parameters to send to the print processor. For more information, see the PrintProcessor property.

PrintProcessor

Data type: string

Access type: Read-only

Print processor service used to process the print job. A printer processor works in conjunction with the printer driver to provide additional translation of printer data for the printer, and can also be used to provide special options, such as a title page for the job.

Priority

Data type: uint32

Access type: Read-only

Importance of a job's execution.

This property is inherited from CIM_Job.

Size

Data type: uint32

Access type: Read-only

Qualifiers: Units (Bytes)

Size of the print job.

StartTime

Data type: datetime

Access type: Read-only

Time that the job began.

This property is inherited from CIM_Job.

Status

Data type: string

Access type: Read-only

Qualifiers: MaxLen (10), DisplayName ("Status")

String that indicates the current status of the object. Operational and non-operational status can be defined. Operational status can include "OK", "Degraded", and "Pred Fail". "Pred Fail" indicates that an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard disk drive).

Non-operational status can include "Error", "Starting", "Stopping", and "Service". "Service" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither "OK" nor in one of the other states.

This property is inherited from CIM_ManagedSystemElement.

Values include the following:

OK ("OK")

Error ("Error")

Degraded ("Degraded")

Unknown ("Unknown")

Pred Fail ("Pred Fail")

Starting ("Starting")

Stopping ("Stopping")

Service ("Service")

Stressed ("Stressed")

NonRecover ("NonRecover")

No Contact ("No Contact")

Lost Comm ("Lost Comm")

StatusMask

Data type: uint32

Access type: Read-only

Bitmap of the possible statuses that relate to this print job.

1 (0x1)

Paused

2 (0x2)

Error

4 (0x4)

Deleting

8 (0x8)

Spooling

16 (0x10)

Printing

32 (0x20)

Offline

64 (0x40)

Paperout

128 (0x80)

Printed

256 (0x100)

Deleted

512 (0x200)

Blocked_DevQ

1024 (0x400)

User_Intervention_Req

2048 (0x800)

Restart

TimeSubmitted

Data type: datetime

Access type: Read-only

Time that the job was submitted.

This property is inherited from CIM_Job.

TotalPages

Data type: uint32

Access type: Read-only

Number of pages required to complete the job. This value may be 0 (zero) if the print job does not contain page-delimiting information.

UntilTime

Data type: datetime

Access type: Read-only

Time at which the job is invalid or should be stopped.

This property is inherited from CIM_Job.

Remarks

The Win32_PrintJob class is derived from CIM_Job.

Examples

The following VBScript code sample describes how to retrieve printer jobs stats from instances of Win32_PrintJob.

Set PrintJobSet = GetObject("winmgmts:").InstancesOf ("Win32_PrintJob")

If (PrintJobSet.Count = 0) Then WScript.Echo "No print jobs!"
for each PrintJob in PrintJobSet
 WScript.Echo PrintJob.Name
 WScript.Echo PrintJob.JobId
 WScript.Echo PrintJob.Status
 WScript.Echo PrintJob.TotalPages
 Wscript.Echo ""
next

The following Perl code sample describes how to retrieve printer jobs stats from instances of Win32_PrintJob.

use strict;
use Win32::OLE;

close (STDERR);

my ($PrintJobset, $PrintJob);
eval {$PrintJobset = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate}")->
 InstancesOf ("Win32_PrintJob") };
if (!$@ && defined $PrintJobset)
{
 if ($PrintJobset->{Count} == 0 ) 
 {
  print "\nNo print jobs!\n";
 }

 foreach $PrintJob (in $PrintJobset)
 {
  print $PrintJob->{Name} , "\n";
  print $PrintJob->{JobId} , "\n";
  print $PrintJob->{Status} , "\n";
  print $PrintJob->{TotalPages} , "\n";
 }
}
else
{
 print Win32::OLE->LastError, "\n";
}

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\CIMV2
MOF
Win32_Printer.mof
DLL
CIMWin32.dll

See also

CIM_Job

Computer System Hardware Classes