Click here to Skip to main content
13,301,553 members (92,243 online)
Click here to Skip to main content
Add your own
alternative version


83 bookmarked
Posted 28 Apr 2007

EnvMan 1.3 - Windows Environment Variables Manager

, 1 Feb 2008
Rate this:
Please Sign up or sign in to vote.
Environment Variables Manager (EnvMan) is a tool written in C# .Net intended to handle the administration of Windows Shell Environment Variables. It is designed to replace Control Panel System Environment Manager and easily manage long variable values.

Main Form

Edit Form


18/12/2007 EnvMan-1.3 Released

  • BT1828033 Escape to Close
    • Added Ctrl+X Shortcut on Main Form Exit File Menu
  • BT843838 Program does not check for changes on Cancel in Edit Form
    • Added checking for user changes and prompt to save it on Cancel.
  • Added Release version display in Main Form Title bar
  • Added colour change for rows with invalid value paths in Main Form
  • Minor GUI Improvements


Environment Variables Manager (EnvMan) is a tool written in C# .Net intended to handle the administration of Windows Shell Environment Variables. It is designed to replace Control Panel System Environment Manager and easily manage long variable values.

EnvMan User Guide


In order to run this program you need to have .Net 2.0 runtime installed. After installing .Net 2.0 runtime download program binaries from the EnvMan Project Website. Unzip file to where you want and set a short cut to EnvMan.exe file to desktop or start menu. You are now ready to run application. In the future I am planning to offer a choice of Windows Installer (MSI) setups and "ClickOnce" for installations and upgrades.

Using a program

Windows Environment Variables Manager (EnvMan) has a simple interface similar to common Environment Variables Editing tool in Systems control panel.

Main screen lists User and System Environment Variables. "New", "Edit", "Delete" buttons allow create new environment variable, edit existing ones and delete. By clicking "New" and "Edit buttons Edit screen is shown.

Enter Variable name and at least one value in the grid to create a new variable. You can use Up/Down arrow buttons on right of the grid to change order of the rows. Folder button allows selecting specific path as a value. Delete button removes selected value from the grid. Once you are ready click Save button or Cancel if no change needed. Changes will be reflected in the Main Screen grid.

Every change performed by side buttons can be undone or redone using arrow buttons. Tool Tip on these buttons shows an action they are going to perform. Keep in mind, if you used undo and then performed an action, every redo command is cleared after that action.

Variable Import/Export

There are two new buttons on the top right of the Edit Form. Variable values can now be exported to an *.env XML file and imported on the different computer or user. The only restriction is that you cannot import values from the different variable. If variable name does not match it will not import and will display a message. It is also possible to create new variables using import. Open new variable by clicking "New" on the Main Form and use import button to import values from selected ENV file. Name of the variable will be loaded as well.

All imported values will have a "+" sign on their type icons.

Open in Explorer context menu

New context menu added to a grid in Edit Form. If right click on the path value of the variable and select "Open in Windows Explorer" it will launch Windows Explorer with first valid folder or file selected. If command used on the non-path value then message will be displayed that no valid paths can be selected.

Running on Vista

To use EnvMan under Vista it should be run with an Administrator privileges. To make it run as Administrator by default open properties of the EnvMan.exe or a shortcut to it.

Select compatibility tab and check "Run this program as an Administrator" check box.

If you want to apply this setting to all users click on "Show settings for all users button" and check "Run this program as an Administrator" check box.

Click OK on every dialog. Now EnvMan.exe will have all the rights to save environment variables. This applies to all versions of the EnvMan.

For more tips and instructions please visit EnvMan project Home Page.

Code behind

System Environment Variables Management

Whole application is based around of idea of using System.Environment class and its GetEnvironmentVariables, GetEnvironmentVariable, SetEnvironmentVariable functions. A list of values separated by ';' is divided into separate strings and loaded into the grid to allow easy manipulation.

Below is an extract of the source code used to load and save environment variables:

public IDictionary GetEnvVariables(EnvironmentVariableTarget varType)
    return Environment.GetEnvironmentVariables(varType);

public string GetEnvVariable(string varName, EnvironmentVariableTarget varType)
    return Environment.GetEnvironmentVariable(varName, varType);

public void SetEnvironmentVariable(string varName, string varValue, EnvironmentVariableTarget varType)
    ValidateVariables(varName, varValue);
    Environment.SetEnvironmentVariable(varName, varValue, varType);

public void DeleteEnvironmentVariable(string varName, EnvironmentVariableTarget varType)
    SetEnvironmentVariable(varName, null, varType);


This program is distributed under the terms of the GNU General Public License v3 or later.

History of Releases and User Guides

Getting Started Guide - V1.0.0.0
Variable value types - V1.1.0.0
Interface improvements - V1.1.0.1
Fixed minimum form sizes - V1.1.0.2
Unlimited Undo/Redo - V1.1.1.0
Save changes on Cancel? - V1.3


Version 1.3

  • BT1828033 Escape to Close
    • Added Ctrl+X Shortcut on Main Form Exit File Menu
  • BT843838 Program does not check for changes on Cancel in Edit Form
    • Added checking for user changes and prompt to save it on Cancel.
  • Added Release version display in Main Form Title bar
  • Added colour change for rows with invalid value paths in Main Form
  • Minor GUI Improvements

Version 1.2.2

  • Fixed problem with Delete button on Edit Form
  • Removed Setup project. It will be replaced by WiX setup.

Version 1.2.1

  • BT1767453 On value edit Undo Redo not recording. Fixed problems when user does not enter text into value cell.
  • BT1792173 Incorrectly detected Value type. Checking that path string is starts with "<drive>:\".
  • BT1806716 Grid Cell accepts semi colon. Added validation DataGridView in Edit form.

Version 1.2

  • Implementation of Import/Export variable values functionality (BT1709867)
  • Implementation of Locate/Open in Windows Explorer Edit Form Grid context menu (BT1729869 - Implemented by PRANKENST!EN)
  • Upgraded license to GPL Version 3

Version 1.1.2

  • Fixed reloading of Main Form on Row double click
  • Added remembering current row and setting it visible after reloading
  • Set Buttons State happens on Data Grid View current selection change
  • Fixed row deletion when user hits delete key on keyboard
  • Added Help Menu new entries.
  • Added credits box in About box
  • Modified CleanAll.bat to work with new projects
  • Added automated build of Setup project


  • Implementation of Undo/Redo functionality (Bug Tracker ID: 1705000)
  • Added Tool Tip info for icons in Edit Form


  • Made single selection in the Edit form grid
  • Set minimum sizes for main and edit forms
  • Fixed bug on renaming variable name


  • Fix alignment of the delete button.
  • Added the current log-on user on Top of User Variables grid
  • Simplify parsing of the variable value string by using string.split function
  • Add settings to save splitter position of the component

Version Released on project site at SourceForge


EnvMan project Home Page

If you have problems getting latest demo and source files from SourceForge try downloading CodeProject files below.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Vladislav Setchin
Software Developer (Senior)
Australia Australia
I have never shared my work online before. Now time has come. I recently started a Software Development Toolbox project. Anyone is welcome to view and add your share to it.

You may also be interested in...

Comments and Discussions

GeneralFeatures suggestion for EnvMan Pin
dzempel12-Jan-11 12:45
memberdzempel12-Jan-11 12:45 
Questionoverwriting indirect (%var%) references? Pin
rpduke15-May-08 14:15
memberrpduke15-May-08 14:15 
AnswerRe: overwriting indirect (%var%) references? Pin
Vladislav Setchin16-May-08 2:26
memberVladislav Setchin16-May-08 2:26 
QuestionHow about a bulk import/export facility Pin
Akshay Dabholkar8-Mar-08 12:43
memberAkshay Dabholkar8-Mar-08 12:43 
AnswerRe: How about a bulk import/export facility Pin
Vladislav Setchin8-Mar-08 19:18
memberVladislav Setchin8-Mar-08 19:18 
GeneralPossible Bug Pin
Bassam Abdul-Baki15-Oct-07 11:21
memberBassam Abdul-Baki15-Oct-07 11:21 
GeneralRe: Possible Bug Pin
Vladislav Setchin15-Oct-07 12:00
memberVladislav Setchin15-Oct-07 12:00 
GeneralExcellent Pin
Bassam Abdul-Baki15-Oct-07 9:18
memberBassam Abdul-Baki15-Oct-07 9:18 
I had started my own implementation for similar reasons, but put it off for a while. Was eventually going to restart it until I saw yours today in the Insider.

I added a couple of features to mine that I'd love to see in yours. Add two columns for string length and cumulative count. The environment path has a limit on what the PATH length could be and I had created mine just for that reason. The length would allow you to sort by long strings and the cumulative would allow you to see the cutoff point. Many a times I tried installing an application and the error was to delete some stuff from the environment path.

Also, didn't see a way to determine broken paths in yours, until I clicked on the edit button. It would be nice if invalid paths (and only paths) were highlighted in red in the main window as well. This would allow users to immediately see paths that could be deleted.



"Oh, what a tangled web we weave, when first we practice to deceive." - Sir Walter Scott

Web - Blog - RSS - Math - LinkedIn - BM

GeneralRe: Excellent Pin
Vladislav Setchin15-Oct-07 11:55
memberVladislav Setchin15-Oct-07 11:55 
GeneralRe: Excellent Pin
Bassam Abdul-Baki15-Oct-07 13:36
memberBassam Abdul-Baki15-Oct-07 13:36 
Generalwhy not add a backup feature Pin
codeprj120-Aug-07 8:34
membercodeprj120-Aug-07 8:34 
GeneralRe: why not add a backup feature Pin
Vladislav Setchin25-Sep-07 11:54
memberVladislav Setchin25-Sep-07 11:54 
GeneralVery nice... Pin
NS174-Jun-07 20:27
memberNS174-Jun-07 20:27 
GeneralRe: Very nice... Pin
Vladislav Setchin5-Jun-07 16:41
memberVladislav Setchin5-Jun-07 16:41 
GeneralRe: Very nice... Pin
NS175-Jun-07 21:59
memberNS175-Jun-07 21:59 
GeneralRe: Very nice... Pin
Vladislav Setchin6-Jun-07 12:43
memberVladislav Setchin6-Jun-07 12:43 
GeneralClickOnce Manager Pin
bob.cohn30-May-07 9:17
memberbob.cohn30-May-07 9:17 
GeneralRe: ClickOnce Manager Pin
Vladislav Setchin2-Jun-07 3:19
memberVladislav Setchin2-Jun-07 3:19 
GeneralNice... Pin
irrdev30-May-07 8:53
memberirrdev30-May-07 8:53 
GeneralRe: Nice... Pin
Vladislav Setchin2-Jun-07 3:13
memberVladislav Setchin2-Jun-07 3:13 
Generalcommercial app. Pin
Mario M.21-May-07 13:55
memberMario M.21-May-07 13:55 
GeneralPromising - but still error-prone... Pin
Marc Scheuner21-May-07 6:49
memberMarc Scheuner21-May-07 6:49 
GeneralRe: Promising - but still error-prone... Pin
Vladislav Setchin21-May-07 13:37
memberVladislav Setchin21-May-07 13:37 
GeneralAbnormal link Pin
Brad Bruce30-Apr-07 4:38
memberBrad Bruce30-Apr-07 4:38 
GeneralRe: Abnormal link Pin
Vladislav Setchin30-Apr-07 12:33
memberVladislav Setchin30-Apr-07 12:33 
GeneralNeat. Pin
Jerry Evans30-Apr-07 2:32
memberJerry Evans30-Apr-07 2:32 
GeneralRe: Neat. Pin
Vladislav Setchin30-Apr-07 12:44
memberVladislav Setchin30-Apr-07 12:44 
GeneralSome additional idea Pin
hsd9929-Apr-07 9:24
memberhsd9929-Apr-07 9:24 
GeneralRe: Some additional idea Pin
Vladislav Setchin29-Apr-07 13:45
memberVladislav Setchin29-Apr-07 13:45 
Question"User variables for" Pin
Uwe Keim28-Apr-07 23:22
sitebuilderUwe Keim28-Apr-07 23:22 
AnswerRe: "User variables for" Pin
Vladislav Setchin29-Apr-07 2:58
memberVladislav Setchin29-Apr-07 2:58 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 1 Feb 2008
Article Copyright 2007 by Vladislav Setchin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid