Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to add a single program among many in a directory to the PATH environmental variable?

Say I have a bunch of programs in D:\utils. Rather than adding D:\utils\ to PATH I want to add D:\utils\utility-5.exe. This doesn't work though.

Is there a way to add it alone, or do I need to move it into its own directory?

share|improve this question
up vote 1 down vote accepted

You will have to put it into a directory.

All the entries in your PATH variable must be directories to be useful. cmd.exe and any other shell or application that uses PATH will try to find the executable corresponding to any command you type by pasting the name of command onto the end of each PATH directory in turn until it either finds the command you asked for or it runs out of directories in your PATH. Any entry that doesn't exist or isn't really a directory will never match anything.

share|improve this answer

You can't add a single executable to the path. There may be an alternative to moving it to another directory, though - assuming it's on an NTFS partition, you could create a symlink to the executable in a directory that is in the path using the mklink command.

share|improve this answer

(Note: I know this is almost 3 years old, but I landed on this page by searching a similar question, so I'm writing the correct answer here for anybody else coming here)

Yes, it is possible, it's even preferred to do this instead of cluttering the PATH variable. You need to add a key under the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths (for the machine) or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths (for the user - preferred).

The format is the same in both cases, the key name should be utility-5.exe and the registry default value should be D:\utils\utility-5.exe.

There are more information (including several more stuff you can do) on MSDN and by Raymond Chen

share|improve this answer

You must log in to answer this question.

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