1.

Solve : batch file help - how to test network connection?

Answer»

i want to write a batch file that tests the whether the computer is connected to the network, and then runs commands based on the result. does anyone know how such a batch file might look?Yes.
That program should:
-ping the gateway to see if it has connection (or other computer in your network); or, if your computer automatically receives ip, just check to see if your computer receives an valid IP
-launch commands/programs

I sugest you to use a programming language like python.
Maybe if you could tell us exactly what commands you want to execute, or describe a litle more your wish, than we will be more ABLE to help you.in a simple batch file, i want to be able to test if my computer is connected to the network (ie, ping the router or check the machine's ip), and if it is not on the network, disable and re-enable the network CARD. i already know how to disable and re-enable the network card from the command LINE, but i want to know how to implement the first part (an IF statment based on the network status) in the batch file, if it's possible.i've discovered a solution to my own problem.

i used an INDIRECT method of testing my network, by getting the computer to test for the existence of a file on itself but USING its network name instead of the file's local directory path. it looks something like this:

IF NOT EXIST \\compname\c\test.txt (
devcon disable PCI\devicecode
devcon enable PCI\devicecode
)You could have just made a simple batch file like this.

ipconfig /all
ping *gateway address*
ping *another computer on the network*
pause

This would tell you if you have connectivity with the gateway and beyond the gateway.  It would also allow you to verify the IP configuration of your computer.  The pause would allow you to see it before it ended so you could have time to verify it.



Discussion

No Comment Found