Link to home
Start Free TrialLog in
Avatar of ojfahoum
ojfahoum

asked on

Batch or script file to check if host is alive

I'm trying to write a script that would check if a host is alive via ping, and if not change it's IP address to the dead host's IP address.

Switching IP address could be done with netsh.  But I'm not sure how to test the result of the ping.

Thanks in advance.
Avatar of Dbaylissnz
Dbaylissnz

Try this


SET CONNECT=an
    PING 104.12.0.234 ¦ FIND "TTL=" > NUL
    IF ERRORLEVEL 1 SET CONNECT=NO
    ECHO %CONNECT% response from device
SOLUTION
Avatar of Tele_tech
Tele_tech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ojfahoum

ASKER

The VBScript worked like a charm.  I couldn't get the batch script to work cause it returned ERRORLEVEL = 1 for everything.  

Thanks for the help!
I'm a newbie to VBScript, so my question is:
How do I run this VBScript in windows ??