How do I connect to internet from command prompt?
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....
atoMerz
Updated on September 18, 2022Comments
-
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.-
Logman almost 11 yearswhat do you do normally? Isnt it on automatically?
-
Raystafarian almost 11 yearsDoes this help?
-
Logman almost 11 years@atoMerz What is disconnecting you? And what does "ipconfig | find /I "Ethernet adapter"" display?
-
atoMerz almost 11 years@Logman see my update.
-
Logman almost 11 yearsHow or what are you connecting? Is it from a laptop (wireless) to a broad band connection? Wired through network adapter?
-
-
atoMerz almost 11 yearsI have already tried
netsh wlan show profiles
andnetsh 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 almost 11 yearsrunning
netsh interface show interface
commands does not display my connection. It only displays the network adapters such (e.g. "Local Area Connection") -
magicandre1981 almost 11 yearshow do you connect to the Internet?
-
Logman almost 11 yearsthat 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 almost 11 yearsI added a picture that shows how I'm connecting. Also it's wired connection.
-
atoMerz almost 11 yearsAdded the picture.
-
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 almost 11 yearsIf you have auto connect on the wifi profile, resetting the adapter will do the same. (ie, my code above).
-
atoMerz almost 11 yearsI get this error: '`' is not recognized as an internal or external command, operable program or batch file.
-
Logman almost 11 yearscan 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 almost 11 yearsHere'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 almost 11 yearsYour 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 almost 11 yearsThis 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 over 10 yearsAt last! P.S. 4 months to find out how to connect to internet from command prompt! Thank you Windows!