首页 > 代码库 > How to get service execuable path
How to get service execuable path
Some time we need to get specific service path and then do something you want. there are 2 way to get specific service path bellow.
private static string GetRegistData(string name) { string registData; RegistryKey hkml = Registry.LocalMachine; RegistryKey system = hkml.OpenSubKey("SYSTEM", true); RegistryKey currentControlSet = system.OpenSubKey("CurrentControlSet", true); RegistryKey services = currentControlSet.OpenSubKey("services", true); RegistryKey key = services.OpenSubKey(name, true); registData = http://www.mamicode.com/key.GetValue("ImagePath").ToString(); return registData; } private static string GetServicePath(string name) { ManagementClass mc = new ManagementClass("Win32_Service"); foreach (ManagementObject mo in mc.GetInstances()) { if (mo.GetPropertyValue("Name").ToString() == name) { return mo.GetPropertyValue("PathName").ToString().Trim(‘"‘); } } return string.Empty; }
How to get service execuable path
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。