Information Technology Reference
In-Depth Information
To restart the Print Spooler service on the local computer, combine the previous two code
segments into a single script, as follows:
'This code will start the print spooler service
'---SCRIPT CONFIGURATION---
strComputer = "."
'---END CONFIGURATION---
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='Spooler'")
For each objService in colServiceList
errReturn = objService.StopService()
Next
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='Spooler'")
For each objService in colServiceList
errReturn = objService.StartService()
Next
WScript.Echo ("Script Complete")
Note that even though the preceding code sends the command to the local computer, you
can perform this action on any computer to which you have access by modifying the value of
strComputer . For example, if the remote computer is named Sales, modify the first line to read
like this:
strComputer = "Sales"
How It Works
You may want to stop and start the Print Spooler service for the following reasons:
￿
You have made changes to network printers or to the server configuration and these
changes are not visible to clients. Even though, ideally, most changes should not require
that the service be restarted, the reality is that this is sometimes necessary.
￿
The printer queue is not despooling documents to the print device due to some technical
problem. Restarting the Print Spooler service will typically clear documents from the
queue so that you can start with a clear printer.
8-9. Pausing, Resuming, and Clearing Printer Queues
Problem
You want to manage the printer queue on your system or on a remote system. In particular, you
want to pause or resume the printer, or clear all documents from its queue.
Search WWH ::




Custom Search