Hi, this is my first article in CodeProject. Not long ago, I was introduced to the world of .NET and the C# programming language, and I liked it very much. Moreover, being a regular visitor of CodeProject, this site helped me strengthen my skills in C#. This tool, NVM, provides me a chance to give something back to the developer community.
Editing and manipulating environment variables is a very cumbersome and non-user-friendly procedure under Windows. NVM aims at making Environment variable administration a simple and user-friendly procedure. It also provides more features than the basic environment variables editor provided by Windows.
I would like to thank Jonathan [Darka] for his SetEnv article and Vladislav Setchin for his EnvMan article which provide great insight on manipulating environment variables through code. I have extended their ideas (but not their code!). This tool is written from scratch, and it gave me an in-depth view of programming with the
DataGridView. I would also like to thank Michael Bright for his great article Registry's Ins and Outs using C# which describes in detail about manipulating the Registry through C#.
Using the program
I built this application using Microsoft Visual Studio 2008 Beta 2 (Orcas), so in order to execute the application, you need to have .NET 3.0 or the .NET 3.5 runtime installed.
Using the code
In the Registry, the User environment variables are stored at:
and the System environment variables are stored at:
So, you can either use the
System.Environment class and its
SetEnvironmentVariable functions to obtain or set the values, respectively, or you can use the
Microsoft.Win32.RegistryKey classes to directly access the Registry.
Once the value is obtained, it is split into tokens based on the separator character ";", and these tokens are displayed in the grid for easy manipulation.
The Export feature allows the user to export the user environment variables and the system environment variables to an XML file.
I have updated the application and released the source code and binary. The following updates have been incorporated:
- A bug related to the New button of the second form has been resolved.
- A Browse For Folder button has been added to the second form. Using this, the user can browse for any folder of his/her choice, and once a folder is selected, its path is added to the Clipboard. This can be used to paste while editing or adding a new value.
- The main form and the second form are now sizable. You can resize the forms to your own requirements.
- The font size has been reduced from size 10 to size 8 to accommodate more data.
I am planning to incorporate the following features in the future versions:
- Add an Import feature to complement the Export feature.
- Add progress bar support while saving to the Registry. As of now, the application hangs for sometime while saving to the Registry. I am looking into this issue. (If anyone has any ideas on how to incorporate this, their suggestions are heartily welcome :) )
Apart from this, if anyone has suggestions for any other features that can be added, do let me know.
Feel free to use the source code and add your modifications. I would appreciate it if you mention my name in the modified code.
- 14-Oct-2007: Released NVM (version 0.9.x) binary and source code.
- 07-Oct-2007: Released the NVM binary.