Hi
i solved myself,but i face another problem,ip,subnet and default gateway successfully changed,but DHCP is changed to 'No'
below is my code chnage ip,subnet and default gateway
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim IPAddress As String = TxtNumIP.Text.Trim
Dim SubnetMask As String = TxtSubnet.Text.Trim
Dim Gateway As String = TxtGateway.Text.Trim
Dim objMC As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim objMOC As ManagementObjectCollection = objMC.GetInstances()
For Each objMO As ManagementObject In objMOC
If (Not CBool(objMO("IPEnabled"))) Then
Continue For
End If
Try
Dim objNewIP As ManagementBaseObject = Nothing
Dim objSetIP As ManagementBaseObject = Nothing
Dim objNewGate As ManagementBaseObject = Nothing
Dim objdhcp As ManagementBaseObject = Nothing
objNewIP = objMO.GetMethodParameters("EnableStatic")
objNewGate = objMO.GetMethodParameters("SetGateways")
objNewGate("DefaultIPGateway") = New String() {Gateway}
objNewGate("GatewayCostMetric") = New Integer() {1}
objNewIP("IPAddress") = New String() {IPAddress}
objNewIP("SubnetMask") = New String() {SubnetMask}
objSetIP = objMO.InvokeMethod("EnableStatic", objNewIP, Nothing)
objSetIP = objMO.InvokeMethod("SetGateways", objNewGate, Nothing)
Catch ex As Exception
End Try
Next objMO
End Sub
pls tell me how give "Yes" for DHCP with above coding
Regards
Aravind