Introduction

This is a tiny utility which stores multiple network and proxy configuration as
profiles. You can apply a profile to set specific network setting and proxy
from simple shortcuts.

Background

If you have a laptop, when you go to different places, you have to change
Network configuration and browser proxy. I have to go to 4 different places
everyday with my laptop; my university, my offices and my home. Everywhere I
have to change my IP setting and IE Proxy. I could write a WMI Script to do all
of them. Unfortunately, for some reason WMI is not working from VB Script in my
laptop but somehow it is working from .NET. So, I have made a handy utility
which I can use to store configuration profiles for different places and apply
them very quickly just by pressing one key and a ENTER at system startup. This
program automatically sets IP, Subnet, Gateway and DNS for my LAN card and also
changes the IE Proxy setting.

Using the code

You can setup in 3 easy steps.

1. Click New and enter a profile name.

2. Set IP configuration

3. Set IE Proxy configuration

It’s even easier to use:

1. Press the first letter of your profile. For example, “h” for Home.

2. Press ENTER and wait as it applies the profile.

3. Press ESC to quit.

Points of Interest

It’s a very simple Winforms application written in C#. The key technologies are:

1. WMI

2. IE Registry tweaking

3. XML Serialization

WMI

Windows Management Intrumentation (WMI) helps you work with Network
configuration. For example, the following code retrieves Network Setting for a
given Network Card.

I have been following your Article and blog for quite a while and really enjoyed it. But this article seems a consolidated version of your previous blog posts and articles, people like me who is following you, will not find any thing new. It is more like publicity thing to sale your new Book, which really sucks. So I urge please come up with new things which you have not voiced, I guess you have still have lot more things to share.

Kudos to Omar for developing this simple yet brilliant program. This program works perfectly on my XP OS on my laptop, but unfortunately it doesn't work on my new Dell laptop which has a Vista business OS. Does this program doesn't support IPv6 or it doesn't support Vista due to incompatible or complex system architecture.

I've test the code (modified) and it runs successfully in Vista Business (I have the annoying 'User Account Control' feature off). You may try either to switch off the UAC feature or edit the code with UAC API.

Hi,
i have implemented your fantastic software (a heaven for me 'cause i frequently change network settings). Right for this reason, i have made some change to your code, and if you want you could view the changes and update your article. Basically i've added a notify icon so you can switch between network configuration in a click, and manage also firefox network configuration. Also, you can edit the default search engines of firefox.

I have looked at many C# implementations of a network configuration tool. While yours is nicely done and cleanly coded, it seems to be missing a major function as do all others I have seen. I may just be blind, but I cannot seem to find a clean function using WMI or API (not registry) that can lookup weather you pull your DNS from the DHCP Server if set to "Obtain IP Address Automatically" or if DNS is set to Static. In the windows tool you can specify DNS servers even if you get your IP from DHCP yet the WMI doesn't seem to have a property or method to return these settings. Can you help me on this one?

If you specify multiple IP address (comma seperated), then the application will not change the IP address.

I'm using this otherwise excellent code to create a network management CmdLet for Powershell, and if I specify multiple IPs, I get a return code of '90' from WMI, which for the EnableStatic method, means 'Parameter out of bounds'. I then downloaded this app, and discovered it also will not deal with multiple, comma-seperated IPs.

Just a little problem that came up using your code:
I have a PC with DHCP setting but an alternative IP-address setting (Windows XP).
When the DHCP server is down then the PC starts with the alternative IP-address.
In this case the application shows nothing as current configuration.

I tried to do the same thing in vc6 since I don't have vs.net,and I don't understand c#.
I used ultraedit to do so. But it is realy difficult. finally i gave up.
could you please post a vc6 demo here? no matter how simple it is.
Thank you very much. My best regards.