QUESTION :
If I have an executable file called “test.exe”, in Command Prompt, the following command will invoke it:
test
However, if I have a shortcut to that same execute elsewhere called “test.lnk”, just typing “test” in Command Prompt doesn’t work. Instead I have to type:
test.lnk
Is there any way for me make test.lnk execute by just typing “test” in Command Prompt?
ANSWER :
for a permanent change you may use this commands:
user-wide (for current user):
setx pathext %pathext%;.lnk
system-wide (for all users on the machine):
setx /m pathext %pathext%;.lnk
setx
makes environment variable instead of session variable, which exists only in the cmd.exe
process where it is set
another solution is to use mklink
to create symlink (symbolic link) instead of shortcuts
eg:
mklink test.exe "c:program filesapplicationtest.exe"
symlinks don’t have .lnk
extension and size
ps:
after using the above mentioned setx
commands you can find your variables here in the environment variables window which can be displayed using this command:
rundll32 sysdm.cpl,EditEnvironmentVariables
pps:
unlike set
, setx
is an external command, ie an executable file, which is located at c:windowssystem32
folder by default, and thus may not exist in some versions or editions of windows
Add ;.LNK to the end of env var PATHEXT
. For a single instance of CMD, you can just SET PATHEXT=%PATHEXT%;.LNK
.
For a permanent change (all CMD going forward), find Advanced System Properties or Advanced System Settings, which occurs in different places on different Windows versions, click Environment Variables
and look under System Variables
(the bottom half).