如何使用可执行文件路径检查是否安装了Windows服务?

时间:2021-08-07 06:58:41

How can I check if a windows service is installed using just the executable path?
I checked the ServiceController class - it lets you use service name and display name but not the executable name to verify.

如何仅使用可执行路径检查是否安装了Windows服务?我检查了ServiceController类 - 它允许您使用服务名称和显示名称,但不能使用可执行文件名来验证。

I only have the executable's FullName available for use in my code. Any ideas?

我只能在我的代码中使用可执行文件的FullName。有任何想法吗?

1 个解决方案

#1


Two options.

  1. WMI. The Win32_Service class's PathName property has the executable command line (so includes parameters).

    WMI。 Win32_Service类的PathName属性具有可执行命令行(因此包括参数)。

  2. Iterate through the registry

    通过注册表迭代

#1


Two options.

  1. WMI. The Win32_Service class's PathName property has the executable command line (so includes parameters).

    WMI。 Win32_Service类的PathName属性具有可执行命令行(因此包括参数)。

  2. Iterate through the registry

    通过注册表迭代