Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for an environment variable editor that handles linebreaks well. I have a monster %PATH% to edit (edited to save side-scrolling):

C:\Program Files\Windows Resource Kits\Tools\;C:\Program Files\PC Connectivity
Solution\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
C:\cygwin\bin;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin;C:\WINDOWS
\system32\WindowsPowerShell\v1.0\;C:\Utils;C:\Program Files\Microsoft SQL 
Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;
C:\Program Files\MKVtoolnix;C:\Program Files\Common Files\Roxio Shared\
DLLShared;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

I want the editor to put each path in a line and when I click save & close, for the editor put the lines back in the right format.

Is there an editor that can do that?

share|improve this question

migrated from stackoverflow.com Dec 4 '09 at 16:48

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 7 down vote accepted

Try out Rapid Environment Editor

alt text

Or based on Dominic's idea:
open up vim

:r !path
:%s/;/\r/g

Fix up your path lines, adding or deleting or modifying them
(delete first blank line)

:%s/\n/;/g
share|improve this answer
    
It's a nice tool! I especially like the feature to reorder paths by CTRL-DOWN/UP. Thanks –  Codism Dec 3 '09 at 17:29
    
awesome, thanks. I had written my own, but that was years ago, and I didn't want to have to maintain mine anymore. –  C Johnson Aug 23 '10 at 15:02

Right click on My Computer > Advanced System Settings (or similar) > Advanced Tab > Environment Variables.

You'll have to do one at a time though.

Alternatively, using CMD you can use the set command to change/add environment variables. You could probably create a script to do this for you, calling the set.exe from a program or batch file.

C:\Users\Callum>set /?
Displays, sets, or removes cmd.exe environment variables.

SET [variable=[string]]

variable  Specifies the environment-variable name.
string    Specifies a series of characters to assign to the variable.

Type SET without parameters to display the current environment variables.

You may also wish to read this and kb Q 104011:

Windows stores the environment variables in the registry under 
HKEY_CURRENT_USER\Environment (for user environment variables) and 
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Environment 
(system environment variables). See also kb Q 104011.
share|improve this answer
1  
That's a single line edit box, which is exactly his problem. –  Dominic Rodger Dec 3 '09 at 16:37

You could always write out a new file, splitting on ; and writing out each component to a new line. Edit in your favourite editor, then join the lines back together with a ;.

You'd just need to write two tiny little utilities.

share|improve this answer
    
Splitting at ; doesn't work in the general case. Consider a PATH like C:\Windows;"C:\My Folder with ; in its name";C:\Program Files\foo;... –  Joey Dec 3 '09 at 16:41
    
Darn. Good point. –  Dominic Rodger Dec 3 '09 at 16:42
    
It will still work in most cases. Just how often do you see ";" in a folder name. –  ldigas Dec 3 '09 at 17:21
    
Oh, I do have such folders. But then again, I regularly break programs with my home path (which includes spaces and an umlaut :-)). –  Joey Dec 3 '09 at 22:25
1  
Yeah, well ... I would have such problems too, if were using my home language. But I do not, so i don't. Let's face it ... in today's computer industry, english is the only language. –  ldigas Dec 4 '09 at 17:02

If this is inside a batch file, you can split the path up into multiple lines like so:

set PATH=C:\Program Files\Windows Resource Kits\Tools\
set PATH=%PATH%;C:\Program Files\PC Connectivity Solution\
set PATH=%PATH%;%SystemRoot%\system32
set PATH=%PATH%;%SystemRoot%
set PATH=%PATH%;%SystemRoot%\System32\Wbem
set PATH=%PATH%;C:\cygwin\bin
set PATH=%PATH%;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin
set PATH=%PATH%;C:\WINDOWS\system32\WindowsPowerShell\v1.0\
set PATH=%PATH%;C:\Utils
set PATH=%PATH%;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\
set PATH=%PATH%;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\
set PATH=%PATH%;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell Common7\IDE\
set PATH=%PATH%;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
set PATH=%PATH%;C:\Program Files\MKVtoolnix
set PATH=%PATH%;C:\Program Files\Common Files\Roxio Shared\DLLShared
set PATH=%PATH%;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

Also, as a side note, I've had problems running JBoss when the PATH contains items that end in backslash. Suggest you avoid the ending backslash on each path item to avoid issues.

share|improve this answer

I found Environment Variable Editor on codeplex that does the job.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.