On Error Resume Next
arrComputers = Array("WORKSTATION001","WORKSTATION002","WORKSTATION003","WORKSTATION004", _
"WORKSTATION005","WORKSTATION006","WORKSTATION007","WORKSTATION008", _
"WORKSTATION009","WORKSTATION010","WORKSTATION011","WORKSTATION012", _
"WORKSTATION013","WORKSTATION014", "WORKSTATION15","WORKSTATION016", _
"WORKSTATION017","WORKSTATION018","WORKSTATION019","WORKSTATION020")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="
Set objShell = WScript.CreateObject("WScript.Shell")
If IsOnline(strComputer) Then
WScript.Echo strComputer & " is Online."
strCommand = "psloggedon.exe -x \\" & strComputer
Set objExec = objShell.Exec(strCommand)
'strInfo = Replace(objExec.StdOut.ReadAll(), vbCrLf, "")
strInfo = objExec.StdOut.ReadAll()
WScript.Echo strInfo
Else
Wscript.Echo strComputer & " is Offline."
End If
Next
Function IsOnline(strPC)
IsOnline = false
strCmd = "%comspec% /c ping -n 2 -w 500 " & strPC & ""
Set objExecObject = objShell.Exec(strCmd)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "Reply") > 0 Then
IsOnline = true
End If
Loop
End Function
Bookmark this post:
|
0 评论:
发表评论