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.

Right now, it's such a mess. Every time I install a new program that does something trivial in the command line, I have to add it to the path. In fact, I'm developing on Ruby and even gems (plugins/extensions) sometimes have their own executables, and are stored in different folders and I end up having to add several paths per application, as well. It's gotten to the point that I am pushing thirty paths in my PATH environment variable.

I'm cautious to copying and pasting them to a home folder of sorts and setting path to that; it just feels wrong. Is there an established best practice that I am missing?

share|improve this question
add comment

3 Answers

up vote 11 down vote accepted

A number of small self-contained utilities reside in my %UserProfile%\Apps folder, such as archivers and the like. Then there are a number of batch files I wrote and frequently use which reside in %UserProfile%\Batches. For the rest, I just add them to the PATH, which is either done by an installer or with

setx PATH "%PATH%;%CD%"

from the appropriate directory. The number of paths there should probably only ever become an issue if the contents get too long (there are length limits for environment variables).

You can (and I sometimes do) write small wrapper batch files for such programs. Simply copying/hardlinking/symlinking the executable into another directory will likely not work on Windows but you can easily create a batch file, for example for the program Foo:

@"%ProgramFiles%\Foosoft Foo\foo.exe" %*

and you can then add the folder where you store those batch files to your PATH.

share|improve this answer
    
+1 for batch file –  ukanth Jun 23 '10 at 7:40
    
How do these wrapper batch files work? Do they work exactly as requiring the actual path? If so, this is amazing. –  Justin L. Jun 23 '10 at 8:36
    
@Justin: They just delegate all arguments given to the batch file to the actual program. Where that resides you'll have to know yourself. –  Јοеу Jun 23 '10 at 8:57
    
Hm; I should clarify -- is there any functional difference between adding the binary's directory to PATH and creating a wapper batch file of the binary into a custom directory that is on the PATH? –  Justin L. Jun 23 '10 at 9:18
    
@Justin: If you use the batch files in batch files again, then there is. Aside from that I'm not aware of any. –  Јοеу Jun 23 '10 at 10:03
show 2 more comments

I am not sure about any specific best practices. But I prefer using GUI PATH Editor tools to manage PATH variables. So that it can be clearly maintained.

List of PATH Editor -

Rapid Environment Editor

Redmond PATH Editor

share|improve this answer
    
Graphical editors might make things a lot easier heh –  Justin L. Jun 23 '10 at 18:36
    
That Redmond PATH editor is exactly the sort of thing I was looking for. +1 –  Nathan Ridley Aug 19 '10 at 11:27
add comment

Now that most Windows machines come with PowerShell, I use many sal/Set-Alias commands in my user profile, so if an app has only one or two apps that I use I'll create aliases for just those two commands instead of adding the whole app folder to the path. Examples include SQL Management Studio, Notepad++, TFS Power Tools (command-line tool, tfpt.exe). I also copy my user profile across machines, so this lets me check for the existence of that app on the current machine before creating the alias (sometimes warning if app isn't installed).

filter ctQuoteString { "`"$_`"" }
filter ctResolvePath { Resolve-Path $_ | select -ExpandProperty Path | ctQuoteString } # used in Edit.ps1

$nppExe = "C:\Program Files (x86)\Notepad++\notepad++.exe"
if ((Test-Path variable:\nppExe) -and (Test-Path $nppExe)) {
    function EditNotepadPP { 
        param ([parameter(ValueFromPipelineByPropertyName=$true)][Alias("FullName","FileName")]$Path) 
        begin { if (! $nppExe) { throw 'variable $nppExe is not defined' } }
        process {
            $Path | ctResolvePath | % { # ctResolvePath will get full path and surround with quotes
                & $nppExe $_
            }
            #AddEditHistory $Path #if you need detailed time tracking, might help to create a log what files you're editting
       } 
    }
    Set-Alias npp EditNotepadPP
}

# I have similar functions for other apps.
Set-Alias vs EditVS
Set-Alias tfe EditTFCheckout
share|improve this answer
add comment

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.