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 conne
I know the question is very old but i had same issue and solve it with this C# code. Maybe it helps to somebody.
First, create vpn connection in your personal computer. It will be storage in %userprofile%\AppData\Roaming\Microsoft\Network\Connections\PBK
then open the rasphone.pbk file with a text editor ( for ex. Notepad++) and copy your connect informations. But don't forget. Before this step, you have to be completed to your connection settings. And then, copy your connection informations from rasphone.pbk file and paste into the script (to rasphone string). Tip: rasphone.pbk file contains just settings. No username and passwords...
In my code, I create a connection with these settings;
Connection Name : RAS -> At first Line [RAS]
Connection Ip : ras.ugurturhal.com
VPN Type: PPTP, supported CHAP and MS-CHAP v2 protocols
The code is check your VPN connections. If you have a connection which name is RAS or IP adress is ras.ugurturhal.com, code changes nothing and warn to you. If you have a lot of VPN connections and none of them have same settings (on above), it will also "ADD" this VPN. And the last thing, if you have no VPN connection, it will be create a new one.
Note: You can't see the VPN connection which you created by C# on your networks. But it will be work. And after the restart to computer, will see it on your networks :)
I hope it will helps to somebody..
And you can download of my project file from my Web Host..
Regards.
PS : I tried to add all of my codes to here but very new in stackoverflow. Please forgive me. You can download the sample ;)
PS2 : Or you can check it from GitHub. Thanks @axrwkr
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:
http://msdn.microsoft.com/en-us/library/aa446741(VS.85).aspx
http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/28125f40-9c3b-4e77-9bfb-8a975e9b3457/
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. :)
My be the CMAK will help (CONNECTION MANAGER ADMINISTRATOR KIT)
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.
I know it's not the "approved" method. but I've been doing this for years without issue.
setup the vpn on your own computer, make sure there is only this one VPN setup in there or you'll deploy all of them to your staff. Find the rasphone.pbk file on your PC, rename it to myVPN.pbk (or whatever you want) and use Altiris or whatever to deploy it to everyones desktop.
When they click on it, it opens up and works fine. As an added benefit put it online and tell your staff to right click on the link and save it to their desktop and dbl click on it. our uni has been doing it this way since I first found it worked most of 10 years ago.