我試圖從SERVICES.MSC獲取服務的可執行文件路徑獲得來自SERVICES.MSC C#的服務路徑
我寫了下面的代碼:
var service = ServiceController.GetServices().Where(p => p.ServiceName.Equals("Service name", StringComparison.InvariantCultureIgnoreCase));
if (service.Any())
//get service data
我couldn`t找到在哪裏(如果所有)服務可執行文件路徑位於何處?
在services.msc中我可以看到路徑,所以我假設它也可以通過代碼來獲取它。
任何想法?
不知道這將有助於這種情況下,但它可能有助於看看WindowsAPICodePack ShellFile類,看看它是否能幫助訪問這些信息 – Thewads
[**如何使用.net?**]獲得windows服務的phyiscal路徑(http://stackoverflow.com/questions/2728578/how-to-get-phy- tion-path-of-windows-service-using-net)和[ **包含可執行文件路徑的ServiceController類**](http://www.codeproject.com/Articles/26533/A-ServiceController-Class-that-Contains-the-Path-t) – Damith