Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically changing Control Panel network options to connect to VPN [duplicate]

Possible Duplicate:
Programmatically changing Control Panel network options to connect to VPN

I offer a VPN service to my users, and a lot of them complain that it's a hassle to set up a new VPN connection and switch to it every time they want to connect to my VPN.

After doing some research I found there are ways to do this programatically, for example:

http://hidemyass.com/vpn/

This service offers a program to connect to their VPN service with a username or password. I can do most of this stuff myself, but what I really need help with is how they would connect to the VPN with the program, and how they do it programatically.

What I'd ideally need to do is in the list below:

  1. Create a temporary new connection to connect to the internet through VPN
  2. Switch to that connection when the user presses "Connect"
  3. When the user presses "Disconnect", switch back to their main connection
  4. Destroy the temporary connection to the VPN

If anyone knows how this is done and could possibly steer me in the right direction, I'd be very grateful. Also I'd prefer to do this in C# but other languages references would be helpful as well. Thanks.

like image 710
Kratz Avatar asked Nov 14 '22 08:11

Kratz


1 Answers

If the VPN connection exists already, you can call rasdial.exe with various parameters...

System.Diagnostics.Process.Start("rasdial.exe", "My_VPN My_Username My_Password"); 

I've had a good look around and can't see a way to actually create the VPN programatically - not saying it isn't possible, but it doesn't look trivial. I'd create the VPN by hand and then connect and disconnect by calling rasdial.

You can use the same Proces.Start method to call rasphone, which could be used to take a user through setting up a VPN... (rasphone -a)

like image 153
Manicguitarist Avatar answered Dec 20 '22 03:12

Manicguitarist