VBScript: Stopping print spooler fails if another service is monitoring/controling it


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
                    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
                    Err = objSpoolerService.StartService()
                    WScript.Sleep 100
                Loop Until Err = 10
            objLogFile.WriteLine "                    Printer Spooler has started."
          End Function

        Function PrintSpoolerRestart
          End Function

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi, have a look at the code here, which determines a service's dependencies, and stops them before stopping the required service:



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
usslindstromAuthor Commented:
I'm looking at the solution you posted.  Give me a minute to work through what it's showing me...
usslindstromAuthor Commented:
That was it!  - Thank you VERY much for the assistance.
No problem. Thanks for the grade.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.