using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace NetMonitorServer { class SetNetworks { public SetNetworks(string data) { if (data.Substring(0,8).ToLower() == "net auto") setNetworkAuto(data); } private void setNetworkAuto(string data) { String[] par = data.Split(' '); if (par.Length != 3) return; Process p1 = new Process(); p1.StartInfo.Arguments = "interface ipv4 set address name=\""+par[2]+"\" source=dhcp"; p1.StartInfo.FileName = "netsh"; p1.Start(); p1.WaitForExit(); Console.WriteLine(p1.ExitCode); Process p2 = new Process(); p2.StartInfo.Arguments = "interface ipv4 set dnsservers name=\"" + par[2] + "\" source=dhcp"; p2.StartInfo.FileName = "netsh"; p2.Start(); p2.WaitForExit(); Console.WriteLine(p2.ExitCode); Process p3 = new Process(); p3.StartInfo.Arguments = "interface ipv4 set winsservers name=\"" + par[2] + "\" source=dhcp"; p3.StartInfo.FileName = "netsh"; p3.Start(); p3.WaitForExit(); Console.WriteLine(p3.ExitCode); } } }