5

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?

0

5 Answers 5

8

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
2
  • It's a nice tool! I especially like the feature to reorder paths by CTRL-DOWN/UP. Thanks
    – Codism
    Dec 3, 2009 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.J.
    Aug 23, 2010 at 15:02
0

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.
1
  • 1
    That's a single line edit box, which is exactly his problem. Dec 3, 2009 at 16:37
0

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.

5
  • 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, 2009 at 16:41
  • Darn. Good point. Dec 3, 2009 at 16:42
  • It will still work in most cases. Just how often do you see ";" in a folder name.
    – Rook
    Dec 3, 2009 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, 2009 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.
    – Rook
    Dec 4, 2009 at 17:02
0

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.

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .