1

I want to start an .EXE file using one command, an abbreviation or alias you could say. For example, I want to open Far Manager using an alias, I have at first to CD into the path, which is c:\Users\myUser\desktop\far\far.exe. I know about the set "alias=myCommand param1 param2" but the problem is I want a single command to open up the application, for example Atom and VSCode have this feature, if I type atom or code in cmd it will open up. so I want to set a single command to open up the application without having to changing the directory into it at first and then use the start command.

2

One way to do this is to add the folder path for the executable to your PATH environment variable.

In Windows 7, 8 and 10, you can:

  1. Open the Start menu
  2. Type "environment variables"
  3. Click "Edit the system environment variables"
  4. Click the Environment Variables button
  5. In the System variables section, select the Path variable and click the Edit button.

Alternatively (also for older versions of Windows):

  1. Right click "Computer", "This Computer" or "This PC" on your desktop.
  2. Click Properties
  3. Click the Advanced Tab
  4. Click the Environment Variables button
  5. In the System variables section, select the Path variable and click the Edit button.

In Windows 10 (and possibly 8?), you will see an edit window that makes it easy to add a path. In prior editions of Windows, you will see a text box edit window. Add the folder path to the end, preceded by a semi-colon: ;c:\Users\myUser\desktop\far\far.exe

enter image description here

1

The simplest solution would be to put your code into a .bat file, then add its folder into the PATH environment variable (or store the file into a folder that is already in the PATH).

To avoid seeing the commands execute, start the file with an @echo off line.

1
  • This would definitely be my approach too. – LPChip Aug 29 '18 at 18:50
1

One more option is to use doskey, which gives a macro function in cmd:-

doskey MacroName=pushd c:\Users\myUser\desktop\far $T start far.exe $ popd

You can add this command to a cmd start-up file.

Yet another option is to set the directory and program name in a program shortcut (eg far.lnk) which you can create in a directory already in your path. Such files can be called direct from cmd.

0

If you want to be able to start a command without having to specify the full path, you have to include the directory in your PATH variable. You can see the current PATH with

echo %PATH%
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.