Publish time 2014-4-5 12:56:57

[2014.04.05] Autoamtically Connect to the Internet by PPPoE at Win7 Operate System

The Best method is useing the bash script (bat) to do the auto connection.
A guy had already wrote a script to his blog. We can use this script to arrive our request.

Step1
Because of I want to remote login the server and I want to automically connect the internet, I install the teamviewer to replace with the RDP
I ignore the installation steps of teamviewer, but please remember the setting of automatically to execute the teamviewer when the the computer enter the os.
http://blessing.bdmv.info/tutorial/connection01.jpg

Step2
If you don't cancel the password protection, you can't automatically execute the startup script when you restart or power on the computer
So, after installing the teamviewer, disable the login password of remote computer, actually, that is dangerous, please consider your situation and make your choice.
http://blessing.bdmv.info/tutorial/connection02.jpg

Step3
Copy the below script to a new test document and change the extension name to bat like 'autopppoe.bat',  guys can consider the below picture to show and change the extension type of the file name in the win7/win server2008 os.
http://blessing.bdmv.info/tutorial/connection03.jpg
@echo off      
ECHO Checking connection, please wait...      
PING -n 1 www.google.com|find "回覆自" >NUL      
IF NOT ERRORLEVEL 1 goto :SUCCESS      
IF     ERRORLEVEL 1 goto :TRYAGAIN
:TRYAGAIN      
ECHO -------------------------------------------------------        
ECHO -------------------------------------------------------      
ECHO FAILURE!      
ECHO Let me try a bit more, please wait...      
@echo off      
PING -n 3 www.google.com|find "回覆自" >NUL      
IF NOT ERRORLEVEL 1 goto :SUCCESS2      
IF     ERRORLEVEL 1 goto :FAILURE
:SUCCESS      
netsh wlan start hostednetwork      
ECHO -------------------------------------------------------      
ECHO -------------------------------------------------------      
ECHO You have an active Internet connection      
:pause      
goto END
:SUCCESS2      
netsh wlan start hostednetwork      
ECHO -------------------------------------------------------      
ECHO -------------------------------------------------------      
ECHO You have an active internet connection but some packet loss was detected.      
:pause      
goto :END
:FAILURE      
ECHO -------------------------------------------------------      
ECHO -------------------------------------------------------      
ECHO You do not have an active Internet connection      
ECHO Reconnecting.. Please Wait      
ECHO -------------------------------------------------------   
ECHO -------------------------------------------------------      
@echo off      
rasdial PPPoE_Connection_name  /DISCONNECT      
rasdial PPPoE_Connection_name PPPoE_Account PPPoE_Password      
ECHO Re-checking Connection, please wait...      
PING -n 3 www.google.com|find "回覆自" >NUL      
IF NOT ERRORLEVEL 1 goto :SUCCESS      
IF     ERRORLEVEL 1 goto :FAILURE
:FAILURE2      
ECHO -------------------------------------------------------      
ECHO -------------------------------------------------------      
ECHO Reconnenction Failed.      
ECHO Please try later.      
:pause      
goto :END
:END
Substituting  the PPPoE_Connection_name、PPPoE_Account and PPPoE_Password to appiciate  as appropriate.

Step4
Cut the script to startup folder.
http://blessing.bdmv.info/tutorial/connection04.jpg

Then, remote restarting the os. If you find the signed in information auto show from teamviewer at the os right corner, it represent the auto connection script script indeed work fine.
http://blessing.bdmv.info/tutorial/connection05.jpg

--------reference--------
利用批次檔來完成 ADSL自動撥號 + 筆電變成無線AP http://mikelong9.blogspot.tw/2014/01/adsl-ap.html
Pages: [1]
View full version: [2014.04.05] Autoamtically Connect to the Internet by PPPoE at Win7 Operate System