Connect to your VPN from the command line

by Steve Wiseman on October 21, 2009 · 2 comments

in Command Line, Tips, Uncategorized

I was setting up an offsite backup system for our source code. I wanted to use the VPN client within windows to connect the two machines.

One of the problems with this idea is that I only wanted this connection to be active while the source code was being copied

It turns out that it is very simple to do. Once you have your VPN connection setup, take note of its name.

VPN Network Name

Then, inside of your batch file you can add this command to connect to the VPN

rasphone -d wimberlynet

Notice, that the name of my network connection was wimberlynet. You would replace that with the name of your network.

At the end of your script, you can disconnect by using this line:

rasphone -h wimberlynet

One gotcha is that you need to make sure you go into the properties of the VPN connection, and make sure prompting is disabled:

VPN Connection Options

And finally, make sure you connect to it once and save the password, and you will be able to totally automate your VPN connection.

{ 2 comments… read them below or add one }

Jennifer Smathers October 21, 2009 at 2:55 pm

Hey Steve, I tried this on my 2003 system. Do you have to call the hangup command twice for it to disconnect? For some reason the VPN connection will not drop unless I call it twice.

Steve Wiseman October 21, 2009 at 3:01 pm

I noticed the same thing. I thought it might be a problem with my machine…so hmm…not sure why you need to call it twice

Leave a Comment

Previous post:

Next post: