Get the shell to recognize shortcuts

Posted on

Problem :

C:Program Files (x86) is dreadful, so I have a directory C:UsersBradenProgramsbin that is in the %PATH% environment variable. This directory is conceptually equivalent to /usr/local/bin on a *NIX system. I.e. A single place where I can throw executables to where I can execute them by just typing their names (whether that’s in a cmd.exe shell or a Run... dialog.). It works fine for straight PE* format executables and batch scripts, but strangely not for shortcuts.

Take VLC, for example. I have a shortcut to VLC named vlc.lnk, which as I understand, is supposed to be the equivalent of a hard link. I have to type in vlc.lnk, not vlc, to get it to execute the program. I find this ridiculous.

Is there some way I can make the commandline treat a .lnk the same way as a .bat or .exe, where I can just type in the filename without the extension? Preferably without installing an external program.

While on the subject, is it possible to do the same with any arbitrary file, like, say, a .bash or .sh file? I could totally get behind a wrapper script written in bash.

Solution :

Try:

ECHO %PATHEXT%
SET PATHEXT=%PATHEXT%;.LNK

Leave a Reply

Your email address will not be published. Required fields are marked *