1

So I've noticed from using the Run thingymabob a lot that for some programs you can simply type in the .exe without specifying the path and it'll run. Chrome, Notepad++, and any native windows apps all can be started like this.

So how is this done? How is it that some programs work like this and others don't? Is it perhaps a registry thing? Or is it something simpler, like putting a shortcut in the right place somewhere?

Hennes
  • 64,768
  • 7
  • 111
  • 168
Obversity
  • 113
  • 4
  • 3
    [PATH variable](http://superuser.com/q/284342/194694). – gronostaj Apr 08 '14 at 08:07
  • Your question was off topic - this site isn't about programming (per se). So, I edited your question, please feel free to undo my changes if you don't like them – Dave Apr 08 '14 at 08:15
  • It's all good David. I'll ask over at StackOverflow if I need a hand editing registry / adding to system variables, now that I know about them. – Obversity Apr 08 '14 at 08:29

2 Answers2

2

You need to change the PATH system variable to include the directory in which you have the executable. This will basically tell windows this: (when the user types in a filename, look for executables in the directories specified in the PATH variable, including this directory).

For windows 7:

Right-click on My Computer => Choose System Properties => Click Advanced System Settings => Advanced tab => Environment Variables , then under System Variables select PATH and click Edit. Add the directory to your desired executable.

For Windows 8:

Control Panel => System => Advanced => Environment Variables , then under System Variables select PATH and click Edit. Add the directory to your desired executable.

Note I: In both cases, if you do not find the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.

Note II: The PATH variable generally looks like this:

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Calibre2\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Windows\SysWOW64;C:\Program Files\Microsoft Network Monitor 3\

To add any new value, insert a semicolon ; followed by the new value (value accepted are obviously absolute paths).

1

The Run dialog looks in several places for the executable. Some of these are:

  1. C:\Windows
  2. C:\Windows\System32

If you place the executable in any of these folders, Run will locate it and execute it. Likewise, if you place a shortcut to the executable in these folders.

However most programs such as Chrome and Notepad++ would either use PATH variables, or the "App Path" registry key, which is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Garrulinae
  • 1,821
  • 15
  • 25
  • Thanks Garrulinae. Marked the other answer as correct simply because it was more detailed, but this was definitely helpful. – Obversity Apr 08 '14 at 08:27