How to open a .exe file using an abbreviation in CMD

How to open a .exe file using an abbreviation in CMD



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:UsersmyUserdesktopfarfar.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.


c:UsersmyUserdesktopfarfar.exe


set "alias=myCommand param1 param2"


start




4 Answers
4



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


PATH



In Windows 7, 8 and 10, you can:



Alternatively (also for older versions of Windows):



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:UsersmyUserdesktopfarfar.exe


;c:UsersmyUserdesktopfarfar.exe



enter image description here



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


.bat



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


@echo off





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



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


doskey


cmd


doskey MacroName=pushd c:UsersmyUserdesktopfar $T start far.exe $ popd



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


cmd



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.


far.lnk


cmd



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


PATH


PATH


echo %PATH%



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế