`
hulunberbus
  • 浏览: 860410 次
文章分类
社区版块
存档分类
最新评论

使用VBS获取当前计算机上开启的服务

 
阅读更多

'获得当前系统服务
Dim oArgs, strServerName, oServiceSet, oWshNetwork

Set oArgs = WScript.Arguments
If oArgs.Count > 0 Then
strServerName = trim(oArgs(0))
Else
strServerName = "LocalHost"
End If
Set oServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strServerName & "/root/cimv2").InstancesOf("Win32_Service")
If strServerName = "LocalHost" Then
Set oWshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo oWshNetwork.ComputerName & " 系统服务信息如下:"
Set oWshNetwork = Nothing
Else
WScript.Echo strServerName & " 系统服务信息如下:"
End If
WScript.Echo String(75, "_")
For each Service in oServiceSet
WScript.Echo " 显示名称:" & Service.Description & "服务名称:" & Service.Name &" 当前状态:" & Service.State

Next
WScript.Echo String(75, "_")
Set oServiceSet = Nothing


WScript.Echo String(75, "_")
Set oServiceSet = Nothing

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics