usslindstrom
asked on
VBScript: Stopping print spooler fails if another service is monitoring/controling it
Experts,
I have some functions written in VBScript that successfully stop/start the print spooler service. This works great, unless there is some other utility that monitors/controls the spooler service. Currently, my enemy is the Dell utilities that are installed if a printer was configured via the CD that came with the unit - but this could be ANY other utility that manages printers, such as HP, Kyocera, etc.
I've pasted what I have for functions in the code block below. My question, is - would anybody be able to point me in the right direction on where I could get information on resolving my problem?
The print spooler service has no problem restarting by itself. If one of the above mentioned utilities has control of the print spooler service, the original script just hangs (since the spooler service can't stop).
I need to stop (and most likely even disable) any service that has control over the print spooler service as well - if there are any.
I have some functions written in VBScript that successfully stop/start the print spooler service. This works great, unless there is some other utility that monitors/controls the spooler service. Currently, my enemy is the Dell utilities that are installed if a printer was configured via the CD that came with the unit - but this could be ANY other utility that manages printers, such as HP, Kyocera, etc.
I've pasted what I have for functions in the code block below. My question, is - would anybody be able to point me in the right direction on where I could get information on resolving my problem?
The print spooler service has no problem restarting by itself. If one of the above mentioned utilities has control of the print spooler service, the original script just hangs (since the spooler service can't stop).
I need to stop (and most likely even disable) any service that has control over the print spooler service as well - if there are any.
Function PrintSpoolerStop
objLogFile.WriteLine " Stopping the Print Spooler service."
wshShell.Run "net stop " & PrinterSpoolerService,0,True
Do
Err = objSpoolerService.StopService()
WScript.Sleep 100
Loop Until Err = 5
objLogFile.WriteLine " Printer Spooler has stopped."
End Function
Function PrintSpoolerStart
objLogFile.WriteLine " Starting the Print Spooler service."
wshShell.Run "net start " & PrinterSpoolerService,0,True
Do
Err = objSpoolerService.StartService()
WScript.Sleep 100
Loop Until Err = 10
objLogFile.WriteLine " Printer Spooler has started."
End Function
Function PrintSpoolerRestart
PrintSpoolerStop
PrintSpoolerStart
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it! - Thank you VERY much for the assistance.
No problem. Thanks for the grade.
Rob.
Rob.
ASKER