tags:

views:

124

answers:

2

I want to build a program to set up a new VPN network on the users machine, and then connect to that network.

The users will be using Windows (Vista or 7).

I am wondering how I would go about setting up a new VPN network programmatically and then have the user connect/disconnect from it at a click of a button.

The network to set up needs to connect to a linux server that I have setup to receive PPTP connections, so that side of it all is done.

ANy help on the matter would be great, as I have Google'd and found nothing that really helps :/

A: 

I think the netsh command (a/k/a "NetShell") would be appropriate here, as it can control the networking functions you are looking for.

As-is, it is a command-line tool that can be used interactively, so you could attempt to create/start/control the connections via shell commands--or better yet, you could programatically hook into the public functions.

(I will note, however, that I have not tried any programmatic control of netsh, so you're on your own there!)

ewall
A: 

I don't see that netsh supports creating VPN connections.

One technique I've found that works is to create the phone book entry directly. On Windows 7, the phonebook can be found in %appdata%\Microsoft\Network\Connections\pbk\rasphone.pbk. Create the entry on another machine, then use that entry to programmatically edit the .pbk files on the target machine (it's just a text file).

Note that this won't save any credentials, so if the user is required to enter credentials, there will still be a necessary authentication step.

Another technique would be to use the API, but I haven't yet attempted this approach.

Jason R. Coombs