Torrents Stats
- Partagées
- 130 Go
- Téléchargées
- 0 bytes
- Ratio
- -
- Messages
- 50
- J'aime
- 1 875
- Trophées
- 378
- Inscrit
- 15 Juin 2018
BONJOUR PETIT TUTO POUR CREER UN VPN :
POUR VOUS CONNECTER AU VPN UNE FOIS CREER ENTRER VOS IDENTIFIANT POUR TROUVER SONT HÔTE ALLER SUR SE SITE : http://www.mon-ip.com/ VOUS Y AUREZ VOTRE HÔTE
POUR COMMENCER :
-CREER 3 TEXT BOX AVEC COMME NOM LA 1 txtHost | La 2 txtUsrname | La 3 txtPassword | La 1 pour l'hote , La 2 pour le nom , La 3 pour le mot de passe
-CREER 2 BOUTON AVEC COMME NOM : btnConnect , btnDisconnect | le 1 pour activer le 2 pour désactiver
En dessous de :
public Form1()
{
InitializeComponent();
}
mettre :
private static string FolderPath => string.Concat(Directory.GetCurrentDirectory(),
"\\VPN");
a mettre dans le bouton activer :
if (!Directory.Exists(FolderPath))
Directory.CreateDirectory(FolderPath);
var sb = new StringBuilder();
sb.AppendLine("[VPN]");
sb.AppendLine("MEDIA=rastapi");
sb.AppendLine("Port=VPN2-0");
sb.AppendLine("Device=WAN Miniport (IKEv2)");
sb.AppendLine("DEVICE=vpn");
sb.AppendLine("PhoneNumber=" + txtHost.Text);
File.WriteAllText(FolderPath + "\\VpnConnection.pbk", sb.ToString());
sb = new StringBuilder();
sb.AppendLine("rasdial \"VPN\" " + txtUsrname.Text + " " + txtPassword.Text + " /phonebook:\"" + FolderPath +
"\\VpnConnection.pbk\"");
File.WriteAllText(FolderPath + "\\VpnConnection.bat", sb.ToString());
var newProcess = new Process
{
StartInfo =
{
FileName = FolderPath + "\\VpnConnection.bat",
WindowStyle = ProcessWindowStyle.Normal
}
};
newProcess.Start();
newProcess.WaitForExit();
btnConnect.Enabled = false;
btnDisconnect.Enabled = true;
}
a mettre dans le bouton désactiver :
File.WriteAllText(FolderPath + "\\VpnDisconnect.bat", "rasdial /d");
var newProcess = new Process
{
StartInfo =
{
FileName = FolderPath + "\\VpnDisconnect.bat",
WindowStyle = ProcessWindowStyle.Normal
}
};
newProcess.Start();
newProcess.WaitForExit();
btnConnect.Enabled = true;
btnDisconnect.Enabled = false;
}
Fichiers joints
Dernière édition: