This is my first time writing a post, so bear with me.
I've made a program for my work and have been asked to implement a feature in it now, where our users are able to connect to our VPN (Always-On VPN), using the program. However, I don't seem to be able to find any information on how to actually establish the connection programmatically. I need to basically be able to click on a button that says "Connect to VPN" and it will then establish the connection, much like it does in Windows when clicking connect:
I've figured out how to see if the connection is established or not via my program:
public bool CheckForVPNInterface()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface @interface in interfaces)
{
if (@interface.Description.Contains("Always-On VPN") && @interface.OperationalStatus == OperationalStatus.Up)
{
Label_Connection.BackColor = Color.Green;
return true;
}
else
Label_Connection.BackColor = Color.Red;
}
}
return false;
}
But now just need to have the "Connect to VPN" button.
Any idea on how to do so?
NOTE: I've tried using rasdial, but that didn't work