Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to be able to type some executable from the command line in windows and have it run, regardless if I am in the folder where the file is located.

How do I set it up or install it so that I can just type someProgram and have it run regardless of my folder location?

share|improve this question
add comment

5 Answers

up vote 8 down vote accepted

Open your system properties (Right click My Computer->properties) Click the Advanced Tab and the envirnment variables button. Look for Path in the System variables section. Then Either put your program in one of the directories listed in that path, or add the install directory to the list. The latter is probably the better option

share|improve this answer
+1 for the answer, but I wouldn't put it in the path in System variables. I'd add a path entry to the User variables section and put it there, unless there's a need for users other than the current user to have access. Why pollute the system path? –  WaldenL May 5 '09 at 13:25
+1 to the comment agreed. It should be in the user section rather than the system section. Thanks for the correction Walden –  Vagnerr May 5 '09 at 13:38
add comment

You would add the path to that program's directory to your PATH environment variable.

share|improve this answer
add comment

You need to have your PATH environment variable set. You can find this in the Control Panel under the System icon, in the "Advanced" tab. Click on the "Environment Variable" button. A second dialog appears with two sections. The top one shows variables that are specific to you, the bottom one, to the entire system. If you want it to just affect you, put the change there, else put it in the bottom.

share|improve this answer
add comment

This is, in every common operating system, the purpose of the PATH-variable.

If you are bound to windows, there is a better way to do it case you want to use that extensively: I used to have it set up for A LOT of programs, so I could start my programs by Win-R (like Start->Run or on the command line), type in a few letters of the executable name, take advantage of the MRU-List and start the application.

The drawback of adding all paths of those executable to the path is that it slows down the command execution: Everytime you call a program, all paths have to be scanned. Therefore, the PATH variable should only be used for directories that contain several executables, like a "bin" or "tools" directory.

The better way is to create a proper entry in the registry, many program installers do that by themself, BTW.

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\

is the place to go. You will already see a lot of entries. AFAIK, this would also allow to have two different commands starting the same program, but in different working directories, or different properties.

Unfortunately, I have not yet found any information from Microsoft/MSDN about the parameters one can find, like RunAsOnNonAdminInstall or BlockOnTSNonInstallMode. We can only speculate on that.

This will also allow you to "rename" the program without actually renaming the executable file (which could get you in trouble if you update it or if it's part of a larger suite) and migrate smoothly if you switch to another favourite application for a certain task. I had vlc and IrfanView start when I typed "wmplayer" and "ACDsee32" accordingly out of habbit/mistake.

THIS is the most exhaustive I ever found about it.

share|improve this answer
add comment

I'd like to add a modern answer to this question (long-tail philosophy of SO sites).

PowerShell is the modern shell on windows. Chocolatey Nuget is a command-line app. It's tagline is 'apt-get for Windows'.

The pattern that Chocolatey uses (which is cloned from package managers for other platforms):

A program and all its EXEs/DLLs are installed to C:\Program Files(x86)\MyCompany\MyApp. But only one EXE is ever used, App.EXE. So chocolatey doesn't add ...\MyCompany\MyApp to the PATH. There is one folder, C:\chocolatey\bin, that has one MyApp.bat file per program. Each bat files has one line that runs the full path to the EXE:

"C:\Program Files(x86)\MyCompany\MyApp\App.EXE" %*

Even if you don't have Chocolatey, I would recommend the same pattern. Create a %USERPROFILE%\Documents\bin folder, and create the .bat file. In PowerShell you can use Set-Alias to do this, add this to your default profile.ps1 file.

share|improve this answer
add comment

Your Answer


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.