string IP = txtIP.Text; string Subnet = txtSubnet.Text; string Gateway = txtGateway.Text; string Nome_Maschera = '"' + Maschera_di_Rete.Nome_Maschera.ToString() +'"' ; DialogResult risultato = MessageBox.Show("Sicuro di voler attribuire i seguenti indirizzi?", "AVVISO", MessageBoxButtons.OKCancel); switch (risultato) { case DialogResult.OK: { string comando; comando = "netsh interface ip set address " + Nome_Maschera.ToString() + " static " + IP.ToString() + " " + Subnet.ToString() + " " + Gateway.ToString(); ProcessStartInfo procStartInfo = new ProcessStartInfo(); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; procStartInfo.FileName = "runas.exe"; procStartInfo.Arguments = "/user:Administrator cmd /K " + comando; Process proc = new Process(); proc.StartInfo = procStartInfo; proc.Start(); string result = proc.StandardOutput.ReadToEnd(); break; } case DialogResult.Cancel: { break; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)