cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lmilesuk
Level 4

Wait till spooler is Started/Stopped

Hi,

I'm creating a Basic MSI project, on uninstall I need to delete some installed dll's, however to do this I need to start/stop the spooler, I can do this in install script using;

ServiceStopService("Spooler");
ServiceStartService("Spooler", "");

At present I have added a Delay(5); after each command before attempting to remove the files, however it can take longer or even be faster for the spooler to start on stop dependent on each users system, is there a way for me to check that the spooler has in fact been stopped or started before continuing execution of the script?

Many thanks in advance
Labels (1)
0 Kudos
(2) Replies
TsungH
Level 12

Out of curiosity, why don't you use MSI built-in functionality ServiceControl Table to stop and start service?
0 Kudos
Not applicable

I agree with TsungH. However if for some reason you can't do that you could use ServiceGetServiceState in a loop which delays say for 1 sec between iterations. After the delay check for the service stopped state. When its stopped you know its safe to proceed.

You might want to put an overall timeout on this though in case the service refuses to shutdown for some reason.
0 Kudos