[Windows] Start-up Auto Connect VPN or ADSL
Windows servers cannot automatically dial and connect VPN or ADSL connections like Linux can with simple commands or startup scripts. However, there are many methods in the Windows environment to achieve this functionality. The simplest method is usually to drag the dial-up connection to the startup directory or add it to the scheduled tasks. However, it is more complicated to set up on a server. Fortunately, Windows provides a tool called rasdial.exe to solve this problem.
To connect to a specific connection using rasdial.exe, the parameters after it are the name of the connection. You can also set a username and password. The connection can be a VPN connection or a dial-up connection like PPOE.
#VPN
rasdial myvpn
#ADSL
rasdial myadsl
#VPN
rasdial myvpn username password
#ADSL
rasdial myadsl username password
To disconnect a specific connection:
#VPN
rasdial myvpn /disconnect
#ADSL
rasdial myadsl /disconnect
To configure it as a system service that starts automatically, you can also configure a system service to achieve a permanent solution. For this, you will need two tools: Instsrv.exe and Srvany.exe, which can be found in Microsoft's Windows Resource Kits. Download link: http://www.microsoft.com/en-us/download/details.aspx?id=17657
Usage:
#Create a service
Instsrv.exe AutoVPNDial Srvany.exe
#Set registry information
reg add Parameters /v HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AutoVPNDial
reg add Application /v HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AutoVPNDial\Parameters /v "%windir%\system32\rasdial.exe myvpn" /t REG_SZ
To remove the system service:
Instsrv AutoVPNDial remove