Most of the posts that I have seen about scripting VPN connections refers to scripting the actual connection “settings” but not the “act” of starting the VPN connection.
Scripting the VPN connection to the server requires that you have already gone in on the workstation physically setup the VPN connection. It’s important that you know the full name of the VPN. In your VPN connections area you can verify what the name of the VPN is. In my example the name of VPN is “Fake Company VPN”.
Once you have verified that you have a connection and that it actually connects you can proceed.
We are going to be using the built in command “Raddial”. If we type “rasdial /?” at the command prompt we would get this:
This command should be pretty straight forward. The only thing that might be a bit confusing is that “entryname” should be identical to what ever you called the VPN connection during it’s setup. In my case I called it “Fake Company VPN”. Because the name has spaces in it we MUST use apostrophe’s.
Open “notepad” and enter the information as such. We are going to be using the command “Rasdial” to script the connection to the server. Please fill in the information as it applies to you and the VPN connection.
Save the contents in Notepad as “vpn-connection.bat”. You’re done! You can now use this script in schedule tasks.
Here’s what the connection will look like from the command prompt view.