Click here to Skip to main content
15,867,453 members
Articles / Desktop Programming / Windows Forms

NVM - eNvironment Variables Manager

Rate me:
Please Sign up or sign in to vote.
3.91/5 (10 votes)
14 Oct 2007CPOL3 min read 52.6K   506   17   15
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 :) )
  • 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)


Written By
Software Developer
United States United States
An individual with more than a decade of experience in desktop computing and mobile app development primarily on the Microsoft platform. He loves programming in C#, WPF & XAML related technologies.
Current interests include web application development, developing rich user experiences across various platforms and exploring his creative side.

Ratish's personal blog: wpfspark.wordpress.com

Comments and Discussions

 
GeneralNice! Pin
Julian Nicholls9-Oct-07 8:44
Julian Nicholls9-Oct-07 8:44 
GeneralRe: Nice! Pin
Ratish Philip9-Oct-07 16:52
Ratish Philip9-Oct-07 16:52 
GeneralRe: Nice! Pin
Julian Nicholls9-Oct-07 23:23
Julian Nicholls9-Oct-07 23:23 
GeneralRe: Nice! Pin
Ratish Philip14-Oct-07 18:06
Ratish Philip14-Oct-07 18:06 
GeneralRe: Nice! Pin
Julian Nicholls15-Oct-07 2:14
Julian Nicholls15-Oct-07 2:14 
GeneralIt crashes !!!!!!!!! Pin
Mohd Amanullah Zafar8-Oct-07 6:27
Mohd Amanullah Zafar8-Oct-07 6:27 
GeneralRe: It crashes !!!!!!!!! Pin
Ratish Philip8-Oct-07 6:29
Ratish Philip8-Oct-07 6:29 
GeneralRe: It crashes !!!!!!!!! Pin
Ratish Philip18-Oct-07 5:42
Ratish Philip18-Oct-07 5:42 
It is fixed now!

Ratish Philip Wink | ;-)

GeneralRolback Option Pin
Mohd Amanullah Zafar8-Oct-07 6:16
Mohd Amanullah Zafar8-Oct-07 6:16 
GeneralRe: Rolback Option Pin
Ratish Philip8-Oct-07 6:19
Ratish Philip8-Oct-07 6:19 
GeneralRe: Rolback Option Pin
Mohd Amanullah Zafar8-Oct-07 6:22
Mohd Amanullah Zafar8-Oct-07 6:22 
GeneralRe: Rolback Option Pin
Ratish Philip8-Oct-07 6:24
Ratish Philip8-Oct-07 6:24 
GeneralWow..... Pin
Mohd Amanullah Zafar8-Oct-07 6:12
Mohd Amanullah Zafar8-Oct-07 6:12 
GeneralCool. Pin
Boinst7-Oct-07 14:57
Boinst7-Oct-07 14:57 
GeneralRe: Cool. Pin
Ratish Philip7-Oct-07 17:28
Ratish Philip7-Oct-07 17:28 

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

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