- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.Net.NetworkInformation;
-
- namespace ChangeIPconf
- {
- public partial class Wind1 : Form
- {
- //commande de base utilisée + paramètres
- string commande = @"c:\windows\system32\netsh.exe";
- string param1 = "";
- string param2 = "";
-
- public Wind1()
- {
- InitializeComponent();
- }
-
- private void Bstatic_Click(object sender, EventArgs e)
- {
- //configuration des paramètres de la commande pour
- //mettre en configuration statique (IP+DNS)
- param1 = "interface ip set address " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " static " + TBip.Text + " " + Tbmask.Text + " " + TBgate.Text + " 1";
- param2 = "interface ip set dns " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " static " + Tbdns.Text;
- SetIpConf(param1, param2); //appel de la méthode qui va lancer le processus
- }
-
- private void Bdhcp_Click(object sender, EventArgs e)
- {
- //configuration des paramètres de la commande pour
- //mettre en configuration dynamique DHCP (IP+DNS)
- param1 = "interface ip set address " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " dhcp";
- param2 = "interface ip set dns " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " dhcp";
- SetIpConf(param1, param2); //appel de la méthode qui va lancer le processus
- }
-
- private void SetIpConf(string p1, string p2)
- {
- //processus qui configure les infos sur l'IP
- ProcessStartInfo proc = new ProcessStartInfo(commande, p1);
- proc.WindowStyle = ProcessWindowStyle.Hidden;
- Process lance = Process.Start(proc);
- Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
- lance.WaitForExit();
- Cursor.Current = System.Windows.Forms.Cursors.Default;
- //processus qui configure les infos sur le DNS
- ProcessStartInfo proc2 = new ProcessStartInfo(commande, p2);
- proc2.WindowStyle = ProcessWindowStyle.Hidden;
- Process lance2 = Process.Start(proc2);
- Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
- lance2.WaitForExit();
- Cursor.Current = System.Windows.Forms.Cursors.Default;
- }
-
- private void Bfermer_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net.NetworkInformation;
namespace ChangeIPconf
{
public partial class Wind1 : Form
{
//commande de base utilisée + paramètres
string commande = @"c:\windows\system32\netsh.exe";
string param1 = "";
string param2 = "";
public Wind1()
{
InitializeComponent();
}
private void Bstatic_Click(object sender, EventArgs e)
{
//configuration des paramètres de la commande pour
//mettre en configuration statique (IP+DNS)
param1 = "interface ip set address " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " static " + TBip.Text + " " + Tbmask.Text + " " + TBgate.Text + " 1";
param2 = "interface ip set dns " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " static " + Tbdns.Text;
SetIpConf(param1, param2); //appel de la méthode qui va lancer le processus
}
private void Bdhcp_Click(object sender, EventArgs e)
{
//configuration des paramètres de la commande pour
//mettre en configuration dynamique DHCP (IP+DNS)
param1 = "interface ip set address " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " dhcp";
param2 = "interface ip set dns " + Convert.ToChar(34) + "Connexion au réseau local" + Convert.ToChar(34) + " dhcp";
SetIpConf(param1, param2); //appel de la méthode qui va lancer le processus
}
private void SetIpConf(string p1, string p2)
{
//processus qui configure les infos sur l'IP
ProcessStartInfo proc = new ProcessStartInfo(commande, p1);
proc.WindowStyle = ProcessWindowStyle.Hidden;
Process lance = Process.Start(proc);
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
lance.WaitForExit();
Cursor.Current = System.Windows.Forms.Cursors.Default;
//processus qui configure les infos sur le DNS
ProcessStartInfo proc2 = new ProcessStartInfo(commande, p2);
proc2.WindowStyle = ProcessWindowStyle.Hidden;
Process lance2 = Process.Start(proc2);
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
lance2.WaitForExit();
Cursor.Current = System.Windows.Forms.Cursors.Default;
}
private void Bfermer_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}