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
  • 379
  • 3
  • 6
  • 13

4 Answers4

3

rasdial "connection name"

or in your case:

rasdial "Bita"

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
  • 3,660
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
  • 3,660
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