Reputation: 79
I wish to run a script at logon each day to test if a PC on the local network is online or not. A message should only be displayed if the PC is offline.
For test purposes using a batch file the closest I have got is this -
@echo off
ping -n 1 192.168.0.6 >nul &&(
START CMD /C "ECHO online && PAUSE"
)||(
START CMD /C "ECHO offline && PAUSE"
)
which opens a window relative to the 'online' message but if I change the IP address to an incorrect one I still get the same message box.
In case it is important both PC's are running windows 10
Thanks
Upvotes: 1
Views: 2536
Reputation: 56180
you probably get Reply from <localhost>: destination unreachable
, which is "success". Better search for TTL=
:
ping -n 1 <address> |find "TTL=" && (
echo Online
) || (
echo Offline
)
Upvotes: 1