.net - Netsh failing to set DHCP in C# -
I am trying to configure DHCP to a network adapter, but I can not find any results. Here is my code:
Private zeros btnResetDHCP_Click (Object Sender, EventArgs E) {NIC nick = (NIC) comboNetworkList.SelectedItem; String cmd = String.Format ("netsh interface ip set address name = \" {0} \ "source = dhcp", nic.Name); Console.WriteLine (cmd); Process P = new process (); ProcessStartInfo psi = New ProcessStartInfo ("Nets", CMD); Psi.verb = "runas"; Psi.WindowStyle = Process WindowStyle.Hidden; P.StartInfo = psi; P.Start (); }
I actually copied and pasted the resultant command printed on the console in the Command Prompt window and successfully converted the adapter into DHCP. However, the above code fails to do anything in the chosen network adapter. Works at the command prompt, but why does not the process through the class?
Comments
Post a Comment