星期四, 九月 14, 2006

(VB.NET)获取服务名

Imports System

Imports System.Management

Module Module1

Public Sub Main()

Dim strComputer = "ComputerName"

Dim wbemServices, wbemObjectSet, wbemObject

wbemServices = GetObject("winmgmts:\\" & strComputer)

wbemObjectSet = wbemServices.InstancesOf("Win32_Service")

For Each wbemObject In wbemObjectSet

Console.WriteLine("服务名称:" & wbemObject.DisplayName)

Console.WriteLine("当前状态:" & wbemObject.State)

Console.WriteLine("启动模式:" & wbemObject.StartMode)

Next

End Sub

End Module

没有评论: