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

EnvMan 1.3 - Windows Environment Variables Manager

By , 1 Feb 2008
 

Main Form

Edit Form

News

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

Introduction

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

Installation

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 EnvMan-x.x.x.x.zip 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);
} 

Licence

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

History

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

Version 1.1.1.0

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

Version 1.1.0.2

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

Version 1.1.0.1

  • 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 1.1.0.0 Released on project site at SourceForge

Support

EnvMan project Home Page

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

License

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
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralFeatures suggestion for EnvManmemberdzempel12 Jan '11 - 11:45 
The EnvMan tool is great. Very nice user interface. I've been running into a little problem though and think that a couple of new features could really help out.
 
1. Flag duplicate entries in the PATH,
 
2. Add an indicator that shows where the maximum PATH length is.
 
thanks for building this great tool and considering these enhancements.
Dave.
Questionoverwriting indirect (%var%) references?memberrpduke15 May '08 - 13:15 
I am having a problem where this app overwrites indirect variable references.
 
ie:
 
define the following in the windows standard enviro var editor:
 
foo = c:\temp
foo2 = %foo%\mydir
 

if variables are edited using envman, then foo2 becomes:
 
foo2 = c:\temp\mydir
 
instead of maintaining the indirect reference.
 
This doesn't seem right to me.
 
Am I missing something?
 
thanks,
rpduke
AnswerRe: overwriting indirect (%var%) references?memberVladislav Setchin16 May '08 - 1:26 
Thanks for posting your message. I was able to replicate this affect and I will further investigate it.
 
If you would like to follow the progress of this investigation sign up to "EnvMan Troubleshooting and Bug Reports" (Forum[^])
 
Cheers,
 
Vlad
 
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox

QuestionHow about a bulk import/export facilitymemberAkshay Dabholkar8 Mar '08 - 11:43 
It is really irritating to migrate environment variables from one machine to another when there is no facility to import/export all variables in one shot. Can you add this to your tool soon?
 
Thanks, and this is a great start for a overlooked facility.
AnswerRe: How about a bulk import/export facilitymemberVladislav Setchin8 Mar '08 - 18:18 
Thanks for your request. I will add it to requested features list.
 
Cheers
 
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox

GeneralPossible BugmemberBassam Abdul-Baki15 Oct '07 - 10:21 
Does it replace all %NAME% with the full path in %PATH% without keeping the string "%NAME%"?
 
In other words, the user %PATH% normally has system %PATH% included. Is that being replaced with the actual content? If so, that's a bug.
 

"Science removes the con from your conscience." - Bassam Abdul-Baki
 
Web - Blog - RSS - Math - LinkedIn - BM

GeneralRe: Possible BugmemberVladislav Setchin15 Oct '07 - 11:00 
Thanks for this one. I will consider adding support for these names in the future releases.
 
Cheers
 
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralExcellentmemberBassam Abdul-Baki15 Oct '07 - 8: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.
 
Thanks
 
5
 

"Oh, what a tangled web we weave, when first we practice to deceive." - Sir Walter Scott
 
Web - Blog - RSS - Math - LinkedIn - BM

GeneralRe: ExcellentmemberVladislav Setchin15 Oct '07 - 10:55 
Hi,
 
Thanks for a good rating and you do have interesting suggestions. I have a proposal for you to join our forces and implement the changes you would like to see in the program. If you would like to contribute make the change a way you want to see it and I will merge it to the main branch for the next release.
 
Thank again for the suggestions and bug report. Problem with delete button is fixed in EnvMan-1.2.2 release.
 
Cheers
 
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralRe: ExcellentmemberBassam Abdul-Baki15 Oct '07 - 12:36 
Thanks. Like I said, I had to put it off since I'm back in school. I'll download the source code when I can and see what other changes I could add and send them to you. If you have the time to work on this, I'd rather you do it yourself since you're more intimately familiar with the code.
 

"I know which side I want to win regardless of how many wrongs they have to commit to achieve it." - Stan Shannon
 
Web - Blog - RSS - Math - LinkedIn - BM

Generalwhy not add a backup featuremembercodeprj120 Aug '07 - 7:34 
i think this feature is valuable
 
gfd

GeneralRe: why not add a backup featurememberVladislav Setchin25 Sep '07 - 10:54 
Hi,
 
Sorry for a late reply. I have few ideas about this one. My thinking is to save a history of the variable changes in some form and provide an ability to restore the previous value.
 
Any suggestions are welcome.
 
Thanks
 
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralVery nice...memberNS174 Jun '07 - 19:27 
You overtook me... Big Grin | :-D
 
Because I had planned to do such a thing, when I had to set the environment variable as part of my project development.
 
Anyway it seems very nice. My hearty congrats!!!
 
When I tried to create a tool to edit environment variables, I had an idea of saving the current settings of all the varibales into a file. So that we can restore the settings in future. I thought that it will be much useful for programmers like us... Hope you can add such a feature also... Smile | :)

 
- NS -

GeneralRe: Very nice...memberVladislav Setchin5 Jun '07 - 15:41 
Thanks for good words of support.
 
Your are the second person who suggested this kind of functionality. I planned to implement Import/Export functions to save variable values into a file. Stay tuned for future releases.
 
Cheers
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralRe: Very nice...memberNS175 Jun '07 - 20:59 
I found a problem... I think it may be a bug... I double click a row in the system variables and updated the value in "edit system variable" dialog. Then I clicked the save button. The value in the main window did not change. But if i do it the same by clicking the edit button in the main window, no problem. I did not try it for user variables...
 
And one more thing is that after the save is done (by the second method I mentioned), the list is scrolled to top making the selection invisible. It will happen even if the cancel is clicked.
 
Hope you will check and correct it in the next release.
 
Anyway now I am using it for editing environment variables... Big Grin | :-D
 
- NS -

GeneralRe: Very nice...memberVladislav Setchin6 Jun '07 - 11:43 
Hi, you really did find a bug with reloading Grid component on Main Form. This is fixed and also I added code to set current selected row visible on refresh. Now grid will scroll down to selected row after edit. Thank you for reporting these issues. Fixes will be available in the next release.
 
This is great to have your support, Everyone! Thanks!
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralClickOnce Managermemberbob.cohn30 May '07 - 8:17 
I've got an application that I use a setting variable for the Connection string to the SQL Server Database and would like to have a tool to manage the varable at installation and not at build...
 
Is this what you're planning? and if so when?
Bob
GeneralRe: ClickOnce ManagermemberVladislav Setchin2 Jun '07 - 2:19 
Well, if I am understanding you right, you need a tool for maintaining windows environment variables from command prompt. I cannot recall the exact name of it, but I think Microsoft has some toolkits that have program for maintaining variables from command prompt. EnvMan is just a graphical tool for easy variable management. Cheers.
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralNice...memberirrdev30 May '07 - 7:53 
This is a good idea. I would consider a "comments" feature. The comments would be stored in a separate file and would link with each Env. variable. The comments could be edited from within EnvMan and would probably help users remember each varable's definition and use. Just an idea.;)
 

GeneralRe: Nice...memberVladislav Setchin2 Jun '07 - 2:13 
You got an interesting idea, but I am wondering, would you really need to have some extra information about a variable? If you are system administrator and work with all the windows settings you would know that anyway, or at least learn it if you really need to. I am just speaking from my experience as a Systems Administrator.
 
Thanks for an idea. Smile | :)
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
Generalcommercial app.memberMario M.21 May '07 - 12:55 
can this be used in a commercial application ?
GeneralPromising - but still error-prone...memberMarc Scheuner21 May '07 - 5:49 
Try highlighting multiple entries in the path dialog box and press the delete key - what exactly gets deleted???
 
If you allow multi-select, you should make sure to actually apply the command chosen to all the items selected, e.g. delete all the highlighted rows, and not something else entirely....
 
=============================
Marc Scheuner, Berne, Switzerland
mscheuner - at - gmail.com
May The Source Be With You!

GeneralRe: Promising - but still error-prone...memberVladislav Setchin21 May '07 - 12:37 
You are right Marc, thanks for pointing that out. I will have to disable multi-select in the grid for now. Implementation of multi-select action on the grid is planned for the future release. Currently it deletes one row from the selection that was clicked last.

 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralAbnormal linkmemberBrad Bruce30 Apr '07 - 3:38 
Please upload your files to CodeProject, instead of leaving them only on Source Forge. Due to the number of questionable files on Source Forge, many web filters ban the site.
 
I've attempted to have our admins open the site, but due to the number of link patterns used by Source Forge, that has proven to be impossible.
 
Thanks.
GeneralRe: Abnormal linkmemberVladislav Setchin30 Apr '07 - 11:33 
Hi,
 
I updated an article with EnvMan-1.1.0.1 release. Now you can find SourceForge link and links to local CodeProject files as well. Let me know if you have any problems getting these files.
 
Thanks
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralNeat.memberJerry Evans30 Apr '07 - 1:32 
I like this. Gets a 5 for implementing a much needed and overlooked utility.
 
One thought: Would it not make the UI slightly simpler if the substrings for any one environment variable were displayed as children in a tree control?
 
(-)INCLUDE
c:\include
r:\src\include
...
 
Thx++
 
Jerry
GeneralRe: Neat.memberVladislav Setchin30 Apr '07 - 11:44 
Thanks for a good rating. You are the second person who suggest to change grid control to a tree view. I had a lot of though about it and I would like to stick to a current design for a few reasons.
 
1. I would like to have the familiar interface that everyone is used to from Windows Control Panel. Just add all the needed functionality to make it easier and pleasant to use.
2. I find that from implementation point of view it will be a little harder with tree view in relation to validations. You will need to work with the whole list at the same time and update and save it correctly. With current design you have a divide and conquer situation where you work with one variable at a time.
 
Thanks
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
GeneralSome additional ideamemberhsd9929 Apr '07 - 8:24 
Hi,
 
My first feeling was, why I should need this tool but rihgt now I like how you handle definition of paths.
I have only one suggestion to provide small function import/export to share selected versiable between computers.
Nice thing will be to give some info to user (by some icon on left side) when some path is not on hard disk.
 
Once again nice work,
ThanksSmile | :)
 
Hsd
GeneralRe: Some additional ideamemberVladislav Setchin29 Apr '07 - 12:45 
Thanks for sharing your idea. At the moment if path is not on the computer it will have an "ABC" icon next to it. I want to change how validation of variable type is done using Regular-Expressions (regex). In case of invalid path it will display a warning icon next to a value with message in the tool tip. Import/export functionality sounds good. I had a similar though before, but was not sure if users would really need it. I am going to put your request into proposed features on the SourceForge bug tracker along with others listed there. You are welcome to add your comments there as well. For this one, I am thinking to use serialization to import; export into XML format for easy comparison in case if someone would like to see a difference between two setups.
 
Thanks again for your comments.
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox
Question"User variables for"sitebuilderUwe Keim28 Apr '07 - 22:22 
The first group box says "User variables for". Did you forget to print the currently active user?
 
And, in addition, is it possible to manage the variables for different users?
 
--
Try our Windows-based CMS: www.zeta-producer.com
Try our ticket helpdesk system: www.zeta-helpdesk.com
See me working: www.magerquark.com

AnswerRe: "User variables for"memberVladislav Setchin29 Apr '07 - 1:58 
Thanks for a tip. I did really forget to display a name of the currently active user. It is fixed now and at the moment will be available from SVN repository until I get a next release ready.
 
Now your question, I did not really intended to make a program that can manage variables for other users under one login. (Is it really possible?) Currently program is reflecting what normal Windows System Control panel screen would do. Different users are able to use it and their setup will be reflected in the top grid.
 
--
"For a Professional Toolbox is a must!"
Visit Vlad's Software Development Toolbox

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

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