Manage Print Jobs

Problem

You want to pause or resume a print job or print queue.

Solution

Use the Pause and Resume methods of the WMI Win32_PrintJob and Win32_Printer classes.

Discussion

WMI isn’t limited to information retrieval tasks (such as those shown in recipe Retrieve Print Queue Information). You can also execute certain WMI class methods to interact with the Windows operating system. One example is the Pause and Resume methods that allow you to manage printers and print jobs.

The following Console application provides a straightforward example. Every time the application finds a print job in the queue, it checks to see if the job or the printer is paused. If so, it tries to resume the job or the printer. Note that Windows permissions might ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.