How do I connect to internet from command prompt?

3

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

atoMerz

Posted 2013-07-15T23:47:00.500

Reputation: 349

2what do you do normally? Isnt it on automatically? – Logman – 2013-07-16T00:03:11.683

Does this help?

– Raystafarian – 2013-07-16T00:09:19.807

@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 – 2013-07-16T05:04:37.357

@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 – 2013-07-16T05:07:55.930

@atoMerz What is disconnecting you? And what does "ipconfig | find /I "Ethernet adapter"" display? – Logman – 2013-07-16T11:06:08.087

@Logman see my update. – atoMerz – 2013-07-16T15:18:10.913

How or what are you connecting? Is it from a laptop (wireless) to a broad band connection? Wired through network adapter? – Logman – 2013-07-16T23:26:29.153

Answers

3

rasdial "connection name"

or in your case:

rasdial "Bita"

user278285

Posted 2013-07-15T23:47:00.500

Reputation:

At last! P.S. 4 months to find out how to connect to internet from command prompt! Thank you Windows! – atoMerz – 2013-12-01T16:02:44.843

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

Logman

Posted 2013-07-15T23:47:00.500

Reputation: 3 452

I get this error: '`' is not recognized as an internal or external command, operable program or batch file. – atoMerz – 2013-07-18T14:37:38.610

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 – 2013-07-18T21:06:50.517

Here's the error: http://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 – 2013-07-19T11:20:34.417

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 – 2013-07-19T21:18:06.940

This is what a wifi connection looks like: http://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 – 2013-07-20T15:52:51.527

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" 

Logman

Posted 2013-07-15T23:47:00.500

Reputation: 3 452

running netsh interface show interface commands does not display my connection. It only displays the network adapters such (e.g. "Local Area Connection") – atoMerz – 2013-07-16T15:22:27.980

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 – 2013-07-16T23:29:56.777

I added a picture that shows how I'm connecting. Also it's wired connection. – atoMerz – 2013-07-17T17:50:23.413

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

magicandre1981

Posted 2013-07-15T23:47:00.500

Reputation: 86 560

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 – 2013-07-16T05:02:19.127

how do you connect to the Internet? – magicandre1981 – 2013-07-16T18:17:28.933

Added the picture. – atoMerz – 2013-07-17T17:50:53.573

">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 – 2013-07-17T22:15:57.210

If you have auto connect on the wifi profile, resetting the adapter will do the same. (ie, my code above). – Logman – 2013-07-17T22:24:30.773