Talk:Service - Functions to Start, Stop, Install, Remove a Service

From ISXKB

Jump to: navigation, search

We've had trouble deleting a service immediately after stopping it I've added code to wait until we can confirm it has stopped. The article says you should wait for a few seconds but does not include any code!

repeat
   Sleep(500);
   if not QueryServiceStatus(service, status) then
      RaiseException('Could not determine status of service while stopping: '+SysErrorMessage(DLLGetLastError));
until status.dwCurrentState <> SERVICE_STOP_PENDING;
Personal tools
Ads: