Saturday, January 24, 2009

Up or Down?

Here is a simple way to see if a computer is alive and well from a CMD script:
SETLOCAL ENABLEEXTENSIONS
FOR /F "skip=1 tokens=6" %%t IN ('ping -n 2 %1 ^|find /i "TTL"') DO SET targetstatus=%%t
IF "%targetstatus%"=="" GOTO down
REM Do Stuff and finish

GOTO :EOF

:down
REM Complain or do other stuff and finish

GOTO :EOF

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.