-2

I need code in vb.net or c# that will be able to change an ip address and dns for static to dynamic and back again. I must also be able to select which connection gets changed.

I have tried multiple differ techniques, but none seem to work

Dim MyAns As Object = MessageBox.Show("Set IP to DHCP?", "IP?", MessageBoxButtons.YesNoCancel)
        If MyAns = vbYes Then
            Process.Start("netsh", "interface ip set address \""Wi-Fi\""    dhcp")
            Process.Start("netsh", "interface ip set dns name=\""Wi-Fi\"" dhcp")
        Else
            Process.Start("netsh", "interface ip add address name=\""Wi-Fi\"" addr=192.168.18.91 mask=255.255.255.0 gateway= 192.168.18.1")
            Process.Start("netsh", "interface ip add dns name=\""Wi-Fi\"" addr=8.8.8.8 primary")
            Process.Start("netsh", "interface ip set dns name=\""Wi-Fi\"" addr=8.8.4.4 secondary")
        End If

I need it to select an ip and change into either static or dynamic as required and maintain it

Dillon
  • 1

1 Answers1

0

Just had to run my visual studios in run as administrator mode

Dillon
  • 1