【问题标题】:Retrieve a list of services running on a server vb.net检索服务器 vb.net 上运行的服务列表
【发布时间】:2012-02-02 11:07:54
【问题描述】:

我正在寻找一种方法来获取服务上运行的所有服务的名称和状态的详细信息。我确实使用了以下代码:

    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?

【问题讨论】:

    标签: vb.net windows-services wmi wmi-query


    【解决方案1】:

    该消息的全部内容是,在尝试导入命名空间时,要么里面什么都没有,要么找不到。

    通常这只是缺少引用的情况,您确定在项目中添加了对 System.ServiceProcess 的引用吗?

    【讨论】:

      猜你喜欢
      • 2020-10-28
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 2011-04-24
      相关资源
      最近更新 更多