How can I execute a shortcut in my path
Solution 1:
One way to do this would to be create Symbolic Links to the files (programs) in question.
Suppose you have a single folder (C:\bin
) that you add to your system path. Then in that folder
you can create Symbolic Links to executables that you want to have quickly accessible.
Now, further suppose that there are several applications that you want to have quick access to, either from the command line or from the Windows/Run box. For example, let's say that your program list includes:
"C:\Program Files\7-Zip\7z.exe"
"C:\Program Files\AutoHotkey\AutoHotkey.exe"
"C:\Program Files\iTunes\iTunes.exe"
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
"C:\Program Files (x86)\Notepad++\notepad++.exe"
To create the symbolic links for the above, you might:
mkdir c:\bin
cd /d c:\bin
mklink 7z.exe "C:\Program Files\7-Zip\7z.exe"
mklink ahk.exe "C:\Program Files\AutoHotkey\AutoHotkey.exe"
mklink iTunes.exe "C:\Program Files\iTunes\iTunes.exe"
mklink devenv.exe "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
mklink npp.exe "C:\Program Files (x86)\Notepad++\notepad++.exe"
You'll notice that I've “renamed” AutoHotKey.exe
to ahk.exe
and Notepad++.exe
to npp.exe
in these examples, thus providing shorthand names for them.
As with many things in Windows, there are other perfectly valid ways to achieve the same thing. One would be create Windows
Command Line Aliases. Another would be to use AutoHotKey. Still another would be to create Windows Shortcuts
and add the .lnk
extension to the PATHEXT
environment variable as @Ben N describes in his answer. Or, you could even use doskey.exe to get there, as described in this post on StackOverflow.
Personally, I primarily use aliases because I tend to use the Windows Command Line a lot. I do also use AutoHotKey, however, when the situation calls for it.
Solution 2:
You need to update the PATHEXT
system environment variable. That variable lists the file types that are considered executable for the purposes of path-searching. Append ;.LNK
to that variable's value, thereby making shortcuts (.lnk
) something that will be searched for on your PATH
. Note that you may need to restart running command prompts for the change to take effect.