Finding out Windows service's running process name .NET 1.1
问题 We are using a badly written windows service, which will hang when we are trying to Stop it from code. So we need to find which process is related to that service and kill it. Any suggestions? 回答1: WMI has this information: the Win32_Service class. A WQL query like SELECT ProcessId FROM Win32_Service WHERE Name='MyServiceName' using System.Management should do the trick. From a quick look see: taskllist.exe /svc and other tools from the command line. 回答2: You can use System.Management