private static void StopService(IntPtr hService) { ServiceInstaller.ControlService(hService, ServiceControl.Stop, new ServiceInstaller.SERVICE_STATUS()); ServiceInstaller.WaitForServiceStatus(hService, ServiceState.Stopping, ServiceState.Stop); }