- Option Explicit
- dim objPing
- dim objStatus
- dim strComputer
-
- strComputer="."
- Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
- ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputer & "'")
-
- For Each objStatus in objPing
- If IsNull(objStatus.ReplySize) Then
- WScript.Echo "computer is offline"
-
- Else
- WScript.Echo "computer is online"
-
- End If
- Next
-
- Set objPing=Nothing
- Set objStatus=Nothing
Option Explicit
dim objPing
dim objStatus
dim strComputer
strComputer="." 'IP Address or Name
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If IsNull(objStatus.ReplySize) Then
WScript.Echo "computer is offline"
'...
Else
WScript.Echo "computer is online"
'...
End If
Next
Set objPing=Nothing
Set objStatus=Nothing
No comments:
Post a Comment