4

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

7
  • 2
    what do you do normally? Isnt it on automatically?
    – Logman
    Jul 16, 2013 at 0:03
  • Does this help? Jul 16, 2013 at 0:09
  • @Raystafarian taken from the link: I would use Task Scheduler to trigger the script on connection to a network, then use the script to confirm presence of the internet. This is exactly what I wnat but, where's this script?
    – atoMerz
    Jul 16, 2013 at 5:04
  • @Logman I'm trying to connect to stay connected to internet during a specific period of day(actually past midnight). I want to make sure I'm connected and if not try to reconnect.
    – atoMerz
    Jul 16, 2013 at 5:07
  • @atoMerz What is disconnecting you? And what does "ipconfig | find /I "Ethernet adapter"" display?
    – Logman
    Jul 16, 2013 at 11:06

4 Answers 4

3

rasdial "connection name"

or in your case:

rasdial "Bita"

1
  • At last! P.S. 4 months to find out how to connect to internet from command prompt! Thank you Windows!
    – atoMerz
    Dec 1, 2013 at 16:02
1

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....

5
  • I get this error: '`' is not recognized as an internal or external command, operable program or batch file.
    – atoMerz
    Jul 18, 2013 at 14:37
  • 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.
    – Logman
    Jul 18, 2013 at 21:06
  • 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.
    – atoMerz
    Jul 19, 2013 at 11:20
  • 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.
    – Logman
    Jul 19, 2013 at 21:18
  • 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
    Jul 20, 2013 at 15:52
0

If it is WIFI/WLAN you can use this:

netsh wlan connect name=<NAME>

Scott Hanselman blogged about it here:

http://www.hanselman.com/blog/HowToConnectToAWirelessWIFINetworkFromTheCommandLineInWindows7.aspx

5
  • 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
    Jul 16, 2013 at 5:02
  • how do you connect to the Internet? Jul 16, 2013 at 18:17
  • Added the picture.
    – atoMerz
    Jul 17, 2013 at 17:50
  • ">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
    Jul 17, 2013 at 22:15
  • If you have auto connect on the wifi profile, resetting the adapter will do the same. (ie, my code above).
    – Logman
    Jul 17, 2013 at 22:24
0

Enable / Disable a network interface from the cmd line

netsh interface set interface name="Local Area Connection" admin=disabled

You might need to change "Local Area Connection", check your *Control Panel\Network and Internet\Network Connections* to get your exact connection name.

My answer to Change DNS with script can be off some help too concerning netsh...

the script below will display network connections and if "Local Area Connection 2" is found it will display the connection. IT will display nothing if "Local Area Connection 2" is not found, so please change it to the connection you want to find.

@ECHO OFF

for /f "usebackq tokens=1,2,3,*" %%A in (`netsh interface show interface`) do (

    if "%%D" == "Local Area Connection 2" (
            ECHO "%%B"   
            netsh interface set interface name="Local Area Connection 2" enabled
    )
)

Must have administrative or elevated user rights.

WIFI:

netsh wlan connect ssid=WiFiNetwork name=Profile1 

netsh wlan connect ssid="Wireless Net" name=Profile2 interface="Wireless Network Connection" 
3
  • running netsh interface show interface commands does not display my connection. It only displays the network adapters such (e.g. "Local Area Connection")
    – atoMerz
    Jul 16, 2013 at 15:22
  • 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.
    – Logman
    Jul 16, 2013 at 23:29
  • I added a picture that shows how I'm connecting. Also it's wired connection.
    – atoMerz
    Jul 17, 2013 at 17:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .