Windows 8.1 How to make Batch Script run a command when it gets a response to ping...


Active Member
Ok so i want a batch file that will run in the background and ping a few servers, and then if it gets a response from any of these servers (If it is able to communicate with them), it executes a command.
It will be running on a machine that in normal operation has no internet (WAN) access, (For security, it doesn't need internet access, just LAN), and i need the batch script to run a command if the machine somehow manages to obtain some sort of internet access. I figured the easiest way would be for it to ping some servers that are unlikely to all be down all at once, (Say,,,, for example), however i don't know how to make a batch file run a command if it gets a response.

Any help greatly appreciated...


Windows Forum Admin
Staff member
Premium Supporter
Microsoft Certified Professional
ping -n 1

You can also probably loop it like:
ping -n 1
goto testping