
Contribution for the week. A novice view. ( Platform WinXP pro ) Short History : A while back when studying C# for the Mbyte Meter project, I came across Windows Management Instrumentation. WMI is something very new to me and was the best suited API for my project. Understanding it is a bit complex but last evening, after weeks of struggling, I managed a break through. There are many on the net who have not been able to succeed with this below. A potential future project came to my mind about creating an automatic Ip address, Gateway and DNS changer tool. This tool will take in set paramenters and the user just has to select the site, activate profile they are on and work away! The code below is for IP address only, but at a much later stage full development will take place. // WMI has classes that assist you interact with hardware on your laptop/desktop/server. In the case of Network Adapters, WMI provides 3 classes. One that is of importance is Win32_NetworkAdapterConfiguration . It has various methods and properties and of use is the EnableStatic Method. Here's part of the code: // Create access to the class object ManagementObject mO = new ManagementObject ("Win32_NetworkAdapterConfiguration.Index='8'"); // The index is the instances of the network cards. // Get the method in-parameters ManagementBaseObject inParams = mO.GetMethodParameters("EnableStatic"); // where EnableStatic is the method of the class // Add input parameters inParams ["IPAddress"] = new string[] {"192.168.1.1"} // Ip Address is an array inParams ["SubnetMask"] = new string[] {"255.255.255.0"} // SubnetMask is an array // Execute the method and obtain return values ManagementBaseObject outParams = ("EnableStatic", inParams,null); I was able to sucessfully change the ip address and mask using the above. Taste of success is sweet!! :-) Rgds.