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?

  • This is such a great question - running programs is so easy on UNIX but such a pain on Windows. Its a shame that the only solutions still seem like such hard work... – user10550 Feb 26 '17 at 17:30

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.

  • 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. – Joey 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. – Joey Jun 23 '10 at 10:03
  • 1
    @barlop: I tend to only do that for console programs anyway ... in my case C, C#, VB compilers, Python, Ruby, &c. and for all those I most certainly expect them to use a console ;-). So no, I don't have a solution. – Joey Mar 19 '12 at 8:26

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

  • 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
  • The question was about MANAGING the variable, not only adding the items . So this is the most correct answer and IMO the best practice as other solutions hide most of the content of the PATH variable. – Maciej Beimcik Sep 27 '17 at 6:07

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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