Recently I needed to develop an VPN Builder for Windows 7 for the L2TP protocol.
To automate the VPN entries on the client and to hide the Private Shared Key for the user.
PowerShell can do this… But does not support the cmdlet Add-VpnConnection onWindows 7
It is only available for Windows 10
1. Download the DotRas Library from the Nuget site
When you have saved the .nupkg package you can just open this using 7-Zip
Extract the nice documentation file DotRas.chm that is included.
And extract the DotRas.dll (for your appropriate .Net version 2.0 or 4.0)
In my case I used the DotNet 2.0 version
2. VB.Net Source code
On the net you can find relevant source code to build your application for L2TP, if you want to have a head start.
And modify to your own needs ….
3. Compile your application
You can use the commandline compiler VBC.exe that is part of your local DotNet installation on any Windows machine.
Or you can use my Visual Studio Light wrapper
%systemroot%\Microsoft.NET\Framework\v2.0.50727\vbc.exe /nowarn /nologo /quiet /debug- /t:Winexe VPN_L2TP_Builder.vb /r:DotRas.dll -out:VPN_L2TP_Builder.exe -win32resource:VPN.res
As you can see I needed to reference the DotRas.dll Assembly and I used the custom Resources to assing a custom ICON and File Properties.
See here on how to build a custom Resource file using Resource Hacker
As you can see we don’t need 10 ton of software, just to build a simple functional DotNet Application
Some extra tips for L2TP errors here
To avoid an “appcrash” you need to make sure that you compile it on the same OS as where the .EXE is going to be used !
In this case it is Windows 7 !