Code Project Pick: “EnvMan 1.2 – Windows Environment Variables Manager”

EnvMan 1.2 – Windows Environment Variables Manager
Click title for source at CodeProject.com…
By Vladislav Setchin


News
11/09/2007 EnvMan-1.2 is released
- 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
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.
New Functionality
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.
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.
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 v2 or later.
About this entry
You’re currently reading “Code Project Pick: “EnvMan 1.2 – Windows Environment Variables Manager”,” an entry on TECH NOTES
- Published:
- October 4, 2007 / 2:12 am
- Category:
- Code Project Picks
- Tags: