Click here to Skip to main content
Click here to Skip to main content

NVM - eNvironment Variables Manager

, 14 Oct 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
NVM is a easy-to-use tool written in C# 3.0. The aim of this tool is to allow easy administration of Windows Environment Variables.

Screenshot - NVM_Main.jpg

Introduction

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.

Background

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:

HKEY_CURRENT_USER\Environment

and the System environment variables are stored at:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment

So, you can either use the System.Environment class and its GetEnvironmentVariables, GetEnvironmentVariable, SetEnvironmentVariable functions to obtain or set the values, respectively, or you can use the Microsoft.Win32.Registry and 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.

Screenshot - NVM_Details.jpg

The Export feature allows the user to export the user environment variables and the system environment variables to an XML file.

Updates

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.

Future Features

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 Smile | :) )
  • 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.

History

  • 14-Oct-2007: Released NVM (version 0.9.x) binary and source code.
  • 07-Oct-2007: Released the NVM binary.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ratish Philip
Software Developer NA
India India
Ratish Philip is a software developer with 8 years of experience. He loves programming in C#, WPF & Silverlight.
 
He is currently exploring the depths of Windows 8 programming.
 
Creating enriched user experiences is what appeals to him the most.
 
Occasionally expresses his creativity through pencil sketching too!
 
Ratish's personal blog: wpfspark.wordpress.com

Comments and Discussions

 
GeneralNice! PinmemberJulian Nicholls9-Oct-07 9:44 
It looks good, albeit with fonts for the visually-impaired Smile | :)
 
Share the wealth, where's the source, dude Smile | :)
 
All the Best
Julian N.
GeneralRe: Nice! Pinmember_Ratish_Philip_9-Oct-07 17:52 
GeneralRe: Nice! PinmemberJulian Nicholls10-Oct-07 0:23 
GeneralRe: Nice! Pinmember_Ratish_Philip_14-Oct-07 19:06 
GeneralRe: Nice! PinmemberJulian Nicholls15-Oct-07 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 14 Oct 2007
Article Copyright 2007 by Ratish Philip
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid