tags:

views:

3621

answers:

4

I have a support environment where we connect to many of our customers' systems using VPN and Remote Desktop. Right now, support personnel have to manually set up the VPN connection on their workstation. Is there a way to programmatically create the VPN connection?

+3  A: 

Look up the RAS API (Remote Access Service), it's a win32 dll, but you can call it from C#. Here are some links that may help you get started:

Ricardo Villamil
+2  A: 

On Windows ras phonebook is stored in a simple ini file that could be found at

C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk

You could prepare such a file at your computer and then deploy this file to customers by simple copying it to the specified path (or append it's content to the existing one). To display new connection in the Network Connections panel, just refreshed explorer's view (via F5 key), no explorer restart is even needed.

Phantomass
A: 

You need a batch script to connect to a VPN that is set up on the base machine. I had a similar problem to deal with a while ago and I found this and this link to be helpful. I have used this solution (first link) in the past so it works but I don't have the batch script anymore.

1.) Include rasphone.pbk in your script (under C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\ in XP. under C:\Users\USERNAME\AppData\Roaming\Microsoft\Network\Connections\Pbk in Vista)

2.) Set working directory to a variable name so you can return to it

3.) Move to the directory where the phonebook is stored using variable names based on the user profile

4.) Test that the phone book is there, if it is, rename it to rasphone.pbk.bk, then xcopy from the script location (as saved in variable) the new phone book to the new place.

5.) Connect.

6.) When ready, disconnect and overwrite the phone book with your settings in with the original file if it is there, else simply delete the phone book.

caglarozdag
I wasn't looking for an automated way to dial. I was looking for an automated way to replicate the VPN settings to multiple workstations.
hurcane
+3  A: 

Check out the DotRas project on CodePlex, the RasPhoneBook component has full support over managing phone books used by Windows.

http://www.codeplex.com/DotRas

It'll be a lot easier than working with the APIs directly, that much I can guarantee. :)