检索在服务器vb.net上运行的服务列表
我正在寻找一种方法来获取服务上运行的所有服务的名称和状态的详细信息。我确实使用了以下代码:检索在服务器vb.net上运行的服务列表,vb.net,windows-services,wmi,wmi-query,Vb.net,Windows Services,Wmi,Wmi Query,我正在寻找一种方法来获取服务上运行的所有服务的名称和状态的详细信息。我确实使用了以下代码: Public Sub GetServices() Dim localServices As ServiceController() = ServiceController.GetServices() For Each service As ServiceController In localServices If Not String.IsNullOrEmpty(s
Public Sub GetServices()
Dim localServices As ServiceController() = ServiceController.GetServices()
For Each service As ServiceController In localServices
If Not String.IsNullOrEmpty(service.DisplayName) Then
dictservice(service.DisplayName) = New Service(service.DisplayName, service.ServiceName, service.Status.ToString)
End If
Next
End Sub
但是,由于我已将项目打包为WCF服务,因此无法使用我使用的System.ServiceProcess命名空间:
有没有其他方法可以检索相同的详细信息?可能是通过wmi?消息的意思是,当尝试导入名称空间时,名称空间中没有任何内容,或者找不到名称空间 通常这只是缺少引用的情况,是否确实已在项目中添加了对System.ServiceProcess的引用