0

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?

2 Answers 2

3

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 files\application\test.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:\windows\system32 folder by default, and thus may not exist in some versions or editions of windows

1

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .