Fog Creek Software
Discussion Board

Environment Variables in Windows - anoying to edit

Is there a beter way to manage 'Environment Variables' in Windows?

It is a major pain to go to Cntrol Panel>System>Advanced and edit the tiny text box.

Is there another way to do this?

Am I the only clutz that is complaining about this? I can't understand why MS could not have designed that better.

Hollandaise Sauce
Saturday, December 13, 2003

Well, it beats the socks off of the original way that environment variables were defined in Windows and DOS: as entries in the Autoexec.bat file. Which only took effect at Windows boot time.

I don't know of a "script" that you can edit. Maybe someone sells a program that provides a better user interface.

Bored Bystander
Saturday, December 13, 2003

To edit a variable with a lengthy value, I copy & paste the current value from the edit dialog to Notepad, edit in Notepad, and then copy & paste it back. 

It would be nice if they made the value edit field in the edit dialog a little bigger and multiline but I don't edit environment variables enough to worry about. 

Saturday, December 13, 2003

I agree that it completely sucks. But the main reason that I need to edit these variables is to modify the classpath for java development. Can't see that being a priority for Microsoft.

Anyone have a Windows-centric reason to modify these variables?

Sunday, December 14, 2003

use SET <envvarname> <yourvalue> in a cmd window

if u wanna prepend or postpend a value can do

SET <envvarname> %envvarname%;<yourvalue>

SET by itself lists the existing variables, adding letters will list env variables starting with those letters

Dan G
Sunday, December 14, 2003

Using SET only changes your local environment (command shell) for the duration of that shell.  Not terribly useful for things you need all the time.

I only have to edit environment variables twice a year; it's pretty rare.  And I have some unusual SDKs.  Most people never need to look there.

Almost Anonymous
Sunday, December 14, 2003

>I can't understand why MS could not have designed
>that better.

Probably because it's typically something that people do very infrequently, hence it doesn't need to be convenient.

Matt Foley
Sunday, December 14, 2003

If you're editing the classpath a lot, just use wrapper batch files to start your compile or run tasks.  It's a band-aid, but it works.

Alternatively, I've (for some projects) wrapped the project with a custom class loader that simply enumerates and uses any JAR files found in a subdirectory of the project.  Makes adding or changing libraries easy.

Sunday, December 14, 2003

The environment registers are stored in the registry. Write a 5 line program to modify that to your heart's contents. If your language of choice doesn't let you do that in 5 lines, switch to Python or KiXtart (or any other language that _can_ do that in 5 lines).

Note that, regardless of HOW you change the environment variable values, changes might not propogate as you expect; E.g, I use VC++6, and after changing the values of the environment variables in the registry, new VC++ started from the "Start" menu will have the new values in their environment. However, double clicking on a .dsw file in Windows Explorer will still have the old values until I close the Explorer window.

Ori Berger
Sunday, December 14, 2003

First of all, you can reach the Environment Variables in 3 key presses: <windows key>-break, ctrl-pgup, alt-e. This should speed things up (if you are inclined to use the keyboard ;-).

About the programmatic approach:
You can cause "interested" running applications to get the new env vars by using the info here:

(very useful during application installs).

Sunday, December 14, 2003

Agreed, it is such a PITA. At the very least, they colud have made the variable editing dialog a bit bigger. What they should do is make its parent dialog resizable, using list views in which one can edit variable name or variable value there and then.

Maybe this is a way of steering people away from environment variables. Judging by the amount I have to use that environment variables box, and the continued existence of PATH, it doesn't work very well.

Insert half smiley here.
Sunday, December 14, 2003

do you need it in a shell? or for the entire machine?

Sunday, December 14, 2003

>Using SET only changes your local environment (command >shell) for the duration of that shell.  Not terribly useful for >things you need all the time.

Microsoft has written program called setx that can set environment variables permanently through the commandline, but it isn't installed by default.  You can read more about this by checking out this site:

Sunday, December 14, 2003

Sorry, for some reason the trailing period was included within the URL.  (This site should really have a preview button...)

Try this link

Sunday, December 14, 2003

| It is a major pain to go to Cntrol Panel>System>Advanced
| and edit the tiny text box.

Uh, so enlarge the text box. Get a resource editor (my personal recommendation: Resource Hacker) and change the guilty dialog in %SystemRoot%\system32\sysdm.cpl, enlarging the textbox, adding the ES_MULTILINE and WS_VSCROLL styles and removing the ES_AUTOHSCROLL style (Resource Hacker doesn't exactly make this intuitive, but not too hard either)

If the system file protection doesn't allow you to save over sysdm.cpl and you don't know how to tell it to shut up, save the result as sysdm2.cpl and use TweakUI to configure the control panel to load the duplicate instead of the original

Monday, December 15, 2003

Thanks, this works like a charm!

mr. envvar
Sunday, May 9, 2004

Can you share your updated system conrol panel so that we do not have to hack it?

Thursday, June 3, 2004

So I hacked the .cpl file and it works fine for a few minutes and then the system restores it to the old one.  The event log shows it happening.  I have admin privileges on the machine. Maybe its time for me to delve into SFP.  I could not figure out how to make my sysdm.cpl file to be invoked when I press Win+Break using TweakUI.

BTW, is there a website that lists all the Win+shortcuts?

Thursday, June 3, 2004

*  Recent Topics

*  Fog Creek Home