G Guest Nov 7, 2004 #1 Hi everybody, Is it possible to start and stop a windows service programatically, i.e. by code? thanks alot guys.
Hi everybody, Is it possible to start and stop a windows service programatically, i.e. by code? thanks alot guys.
J Jay B. Harlow [MVP - Outlook] Nov 7, 2004 #2 Avi, Yes, see the online help for System.ServiceProcess.ServiceController. http://msdn.microsoft.com/library/d...serviceprocessservicecontrollerclasstopic.asp http://msdn.microsoft.com/library/d...vbcon/html/vboriMonitoringWindowsServices.asp Specifically the Stop, Start, and WaitForStatus methods along with the CanStop property. For example I use code similiar to the following to "Restart" a service: controller.Stop() controller.WaitForStatus(ServiceControllerStatus.Stopped) controller.Start() Hope this helps Jay
Avi, Yes, see the online help for System.ServiceProcess.ServiceController. http://msdn.microsoft.com/library/d...serviceprocessservicecontrollerclasstopic.asp http://msdn.microsoft.com/library/d...vbcon/html/vboriMonitoringWindowsServices.asp Specifically the Stop, Start, and WaitForStatus methods along with the CanStop property. For example I use code similiar to the following to "Restart" a service: controller.Stop() controller.WaitForStatus(ServiceControllerStatus.Stopped) controller.Start() Hope this helps Jay