Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Run a command only when internet connection available

- - - - -

  • Please log in to reply
1 reply to this topic




  • Member
  • PipPip
  • 137 posts
  • Joined 14-March 08
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?

How to remove advertisement from MSFN



    The Finder

  • Developer
  • 16,010 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
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:
for some example/links.

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


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users