MSFN Forum: Run a command only when internet connection available - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Run a command only when internet connection available Rate Topic: -----

#1 User is offline   Nick_White 

  • Member
  • PipPip
  • Group: Members
  • Posts: 137
  • Joined: 14-March 08

Posted 02 March 2010 - 07:50 AM

I have to run a command automatically at startup. For this, I use a CMD file.

The problem is the program needs internet connection. If it doesn't, then it will timeout and exit.
When Windows logs on, the network connection is not available yet (DHCP).

Can I do something like: loop a command to check internet connection (an address like www.google.com), and when it's available, do the rest of the commands?


#2 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,107
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 02 March 2010 - 08:15 AM

Sure :yes: , you ping some server (you need a pingable address, some DNS aren't) and you should use an actual IP, as you may have internet connection but the DNS may not be available, depending on the result of the ping conditionally execute the command.

See here:
http://www.msfn.org/...howtopic=131680
http://www.msfn.org/...howtopic=139853
for some example/links.

Essentially you need a single line like:
@ping 74.125.53.106 -n 1 >NUL&&ECHO OK, FOUND!


jaclaz

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy