Search code examples
cmdexepath-variables

Run .exe anywhere in cmd without PATH variable


This works (Notepad++):

C:\Anywhere> start notepad++ hello.txt

And this works (SoX for removing silence in sounds):

C:\Anywhere> sox in.wav out1.wav silence 1 0.1 1%

Yet, my PATH variable includes neither (would send on request).

How can I do this with my program?
To run from everywhere.

Also, why doesn't Notepad++ work without the start command?

(I did this workaround by putting the .exe in C:\ and then simply calling C:\Anywhere> /myprogram but I'm still curious about the above.)


Solution

  • To get the indicated scenario where

    • you can start applications from anywhere using the start command (or the windows Run dialog) without including its parent folder in path variable,
    • but you can not start the application without the start command from any directory whithout including the full path to reach it (it is not in the path) or being located in the adecuated directory

    the applications are included in the registry under the key

    HKEY_CLASSES_ROOT\Applications
    

    note: It is a "merged" view showing the combined contents of

    HKEY_LOCAL_MACHINE\Software\Classes\Applications
    HKEY_CURRENT_USER\Software\Classes\Applications
    

    If you are not administrator to change the local machine configuration, you can always modify your user registry information to include the applications you need.

    edited There is a second place in registry that will allow to include an application in the registry to be executed using start command, Run dialog or from anything that uses the ShellExecute or ShellExecuteEx API calls.

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