• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
Sign in to follow this  
Followers 0

Run a command only when internet connection available

2 posts in this topic

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?


Share this post

Link to post
Share on other sites

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!



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.