How do I connect to internet from command prompt?

30,885

Solution 1

rasdial "connection name"

or in your case:

rasdial "Bita"

Solution 2

Copy the text below into a text file and save it as a *.bat file Change connect name if needed.......

@ECHO OFF

ping 8.8.8.8 | find "unreachable"

if errorlevel 1 goto :eof

netsh wlan connect name="Bita"

pause

@magicandre1981 has part of the answer,maybe a mod can merge my answer into his....

Share:
30,885
atoMerz
Author by

atoMerz

Updated on September 18, 2022

Comments

  • atoMerz
    atoMerz almost 2 years

    I'm trying to create a task that connects to internet at a specified time. I have a broadband wired connection that I use to connect to the internet. How do I manage connect/disconnect of this connection from command prompt?

    Update/Additional Info:
    Here's the actual situation:
    My ISP offers free download from 2:00AM to 7:00AM. Thus I schedule my downloads during that period. I've been doing this without any problems until recently, when by looking at the logs I noticed I'm being disconnect sometime before 2:00AM. I have checked the auto reconnect on my connection for such cases but (again by checking the logs) I'm not able to reconnect automatically. So I'm guessing during that period of time (maybe for a few minutes) I cannot reconnect. So I want to check my connection at around 2:10AM and if it's disconnected, I want to reconnect it. Which brings us the the question of:
    How do I schedule a windows task to connect to a broadband connection?
    P.S. I know reconnection is possible. I tried it once, sometime around 3:00AM and it worked.

    Update2: This is how I connect
    Note: Do not be mistaken, this is NOT a wireless connection.

    enter image description here

    • Logman
      Logman almost 11 years
      what do you do normally? Isnt it on automatically?
    • Raystafarian
      Raystafarian almost 11 years
      Does this help?
    • Logman
      Logman almost 11 years
      @atoMerz What is disconnecting you? And what does "ipconfig | find /I "Ethernet adapter"" display?
    • atoMerz
      atoMerz almost 11 years
      @Logman see my update.
    • Logman
      Logman almost 11 years
      How or what are you connecting? Is it from a laptop (wireless) to a broad band connection? Wired through network adapter?
  • atoMerz
    atoMerz almost 11 years
    I have already tried netsh wlan show profiles and netsh wlan show interfaces neither shows my connection. neither shows the connection I'm using. I guess it's because it's not wireless connection?
  • atoMerz
    atoMerz almost 11 years
    running netsh interface show interface commands does not display my connection. It only displays the network adapters such (e.g. "Local Area Connection")
  • magicandre1981
    magicandre1981 almost 11 years
    how do you connect to the Internet?
  • Logman
    Logman almost 11 years
    that cmd "netsh interface show interface" displays Control Panel\Network and Internet\Network Connections... that is where you enable/disable connect/disconnect internet connections. Unless you are talking about connecting to a specific WIFI hot spot. Which should be set to auto connect whenever you enable/disable or connect/disconnect from a network adapter.
  • atoMerz
    atoMerz almost 11 years
    I added a picture that shows how I'm connecting. Also it's wired connection.
  • atoMerz
    atoMerz almost 11 years
    Added the picture.
  • Logman
    Logman almost 11 years
    ">netsh wlan show network" will display the wifi networks, and then use @magicandre1981 cmd ">netsh wlan connect name=BitA". You can run magicandre1981 alone even if you are connected, it will reset the connection otherwise you need to check to see if the connection is down.
  • Logman
    Logman almost 11 years
    If you have auto connect on the wifi profile, resetting the adapter will do the same. (ie, my code above).
  • atoMerz
    atoMerz almost 11 years
    I get this error: '`' is not recognized as an internal or external command, operable program or batch file.
  • Logman
    Logman almost 11 years
    can you post a screen shot of the batch cmd window err? The "pause" isonnly there so you can see the err, otherwise remove if it works. Test the script lines #2 & #4 one by one.... disconnect your wifiand run "netsh wlan connect name="Bita"" from cmd prompt. It should reconnect. As @magicandre1981 answer states.
  • atoMerz
    atoMerz almost 11 years
    Here's the error: oi41.tinypic.com/2dme009.jpg . I'm sure I said this before, but just to make sure we're on the same track "I'm NOT using wifi". It's a Broadband wire ADSL connection.
  • Logman
    Logman almost 11 years
    Your image shows a wifi connection... "Bita". So are you using wifi from a laptop or not? And if you are... and its not the wifi "Bita" you want to reconnect then which one? If its not the Ethernet adapter interface (wired), and not a wifi then what connection? Reset the router? If its the router that needs to be reset, its time to buy a new router.
  • atoMerz
    atoMerz almost 11 years
    This is what a wifi connection looks like: i40.tinypic.com/5vobbt.png . And my connection "Bita" is obviously not one of them. Reconnection requires no router reset AFAIK, a few minutes after the aforementioned disconnect, reconnect should be possible.
  • atoMerz
    atoMerz over 10 years
    At last! P.S. 4 months to find out how to connect to internet from command prompt! Thank you Windows!