servicecontroller

how to get phyiscal path of windows service using .net?

*爱你&永不变心* 提交于 2019-11-27 03:15:08
问题 I have to get the absolute path of a windows service in a .Net Admin application. I am using ServiceController of .Net as shown below. ServiceController serviceController = new ServiceController(serviceName); But I don't see any property here to get the absolute path of the .exe of the service. Is there anyway to get this programmatically. 回答1: You can get this using WMI, which requires an assembly reference to System.Management: using System.Management; class Program { static void Main

ServiceController permissions in Windows 7

会有一股神秘感。 提交于 2019-11-26 14:08:48
问题 I have an application which consists of a service and an executable. Essentially it's a forms application that is responsible for starting and stopping a service under specific circumstances. On Windows XP the application manages this fine using the following code: ServiceController controller = new ServiceController(); controller.MachineName = "."; controller.ServiceName = "XXXXXXXXXX"; controller.Stop(); controller.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 10));