Topic: Wait for network connection in batch file.

Hello in my universal image i run things automatically after the image applys however i need the network for some things to work.
I currently just use a sleep command to wait about 60 seconds but i was wonder about a better way.

Re: Wait for network connection in batch file.

That's what I'd do. Sweet and simple smile

Re: Wait for network connection in batch file.

ping -n 20 IPaddress

might work nicely...
use the built in timeout feature as a delay wink
you could even use a bigger number or longer timeout (-w 9999 is about ten seconds)

so  "start /wait ping -n 20 -w 9999 192.168.1.1" would pause execution and wait up to 200 seconds for the connection to become live.

once the connection is live the replys will come quickly and the timeout will automaticaly end smile


Bashrat is not the only sneaky one wink tongue

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.

Re: Wait for network connection in batch file.

Or you could use AutoIT like so...

Local $t, $p
Do
   $p = Ping("pbmain1","3000") ; or IP address
   $t = $t + 1
Until $p > 0 or $t = 10 ; So do this until it connects or wait 30 seconds of timeouts

Last edited by stamandster (2009-05-14 23:12:51)

Re: Wait for network connection in batch file.

Thanks for the ideas guys, i will look into them when i get some time tongue
However i thought the ping thing didn't work because if there network isnt activated yet, pings don't get sent.
Instead of timeouts it says something like unknown command or something.

Re: Wait for network connection in batch file.

PING 127.0.0.1 works without an active network smile

Re: Wait for network connection in batch file.

Ping will work as long as tcpip is installed... we are taking advantage of the fact that the target is not reachable until the network is live smile

DP BartPE Tutorial   DP_BASE Tutorial   HWID's Tool     Read BEFORE you post    UserBars!
http://driverpacks.net/userbar/admin-1.png
The DriverPacks, the DP_Base program, and Support Forum are FREE!.