- last login
- 2024-8-23
- online
- 1027 hour
- regtime
- 2011-11-28
- readperm
- 200
- credits
- 3955
- posts
- 501
|
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.
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.
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.
- @echo off
- ECHO Checking connection, please wait...
- PING -n 1 [url]www.google.com[/url]|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 [url]www.google.com[/url]|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
Copy the Code Substituting the PPPoE_Connection_name、PPPoE_Account and PPPoE_Password to appiciate as appropriate.
Step4
Cut the script to startup folder.
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.
--------reference--------
利用批次檔來完成 ADSL自動撥號 + 筆電變成無線AP http://mikelong9.blogspot.tw/2014/01/adsl-ap.html
|
|