Export (0) Print
Expand All

CancelAllJobs method of the Win32_Printer class

The CancelAllJobs WMI class method removes all jobs, including the one currently printing from the queue.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax


uint32 CancelAllJobs();

Parameters

This method has no parameters.

Return value

Return codeDescription
0

Success

5

Access Denied

 

Examples

The Notify Users When a Print Queue is Purged uses Msg.exe to send a network alert to any users who had documents in a print queue about to be purged. After sending the alerts, the script purges the print queue.

The Delete all print jobs VBScript code sample deletes all print jobs on the local computer.

The following VBScript sample deletes all the print jobs for a printer named HP QuietJet.


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 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Namespace

\root\CIMV2

MOF

CIMWin32.mof

DLL

CIMWin32.dll

See also

Computer System Hardware Classes
Win32_Printer

 

 

Show:
© 2014 Microsoft