Dear all
i am developing an application which will change the ip address of the server. the Ip is configured manually (i.e static ip configuration). i have written the following code to do so
	the code is not giving any error and when i check the log file created, it shows the message that the new ip is assigned. but when i check in the Local area connection status, it shows the same old ip..
any help will be greatly appreciated..
Regards:
					i am developing an application which will change the ip address of the server. the Ip is configured manually (i.e static ip configuration). i have written the following code to do so
Code:
	private void setIP(string ip_address, string subnet_mask)
        {
           ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection objMOC = objMC.GetInstances();
            foreach (ManagementObject objMO in objMOC)
            {
                if ((bool)objMO["IPEnabled"])
                {
                    try
                    {
                        ManagementBaseObject setIP;
                        ManagementBaseObject newIP =
                            objMO.GetMethodParameters("EnableStatic");
                        newIP["IPAddress"] = new string[] { ip_address };
                        newIP["SubnetMask"] = new string[] { subnet_mask };
                        setIP = objMO.InvokeMethod("EnableStatic", newIP, null);
WriteLog("Ip changed, new IP assigned is "+ip_address + System.Environment.NewLine + "=================" + System.Environment.NewLine);
                    }
                    catch (Exception ex)
                    {
                        WriteLog("Error Occured.. " + ex.Message.ToString() + System.Environment.NewLine + "=================" + System.Environment.NewLine);
                    }
                }
            }
        }
any help will be greatly appreciated..
Regards:
	
Comment