Use VBS to get the service on the current computer

xiaoxiao2021-03-06  73

'Get the current system service Dim Oargs, StrserverName, Oserviceet, OWSHNETWORK

Set oArgs = WScript.ArgumentsIf oArgs.Count> 0 Then strServerName = trim (oArgs (0)) Else strServerName = "LocalHost" End IfSet 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 &" system information as follows: "Set oWshNetwork = NothingElse WScript.echo strservername & "System service information is as follows:" End ifWscript.echo String (75, "_") for Each Service In Oservice Set Wscript.echo "Display Name:" & Service.Description & "Service Name:" & Service. Name & "Current Status:" & Service.State

NextWScript.echo String (75, "_") set oserviceet = nothing

WScript.echo String (75, "_") set oserviceet = Nothing

转载请注明原文地址:https://www.9cbs.com/read-121279.html

New Post(0)