Setting Command Aliases on Windows

On Windows, aliases can be set for the Command Prompt similar to how one would set shell aliases on Linux or macOS, however, the process is slightly more complicated and requires making a change in the Windows registry.

Caution:You can modify the Windows registry by running regedit from Run in the Start Menu and then navigating to the desired key path. Be very careful when editing the registry. If you are not comfortable navigating and making changes to the registry, enlist the help of someone who is.

 

1. Create a folder where you want to store the file containing your alias commands- e.g. C:\Users\<username>\.cmds

2. In the above directory create a text file called cmds.bat

3. Edit cmds.bat with the following syntax for aliases (an example is shown below for Canopy):

@echo off 

doskey alias_name="command"

4. Open regedit

5. Navigate to HKEY_CURRENT_USER => Software => Microsoft => Command Processor

6. Add a String valued entry with the name AutoRun. For the value, enter the full path to the cmds.bat file your created - e.g. C:\Users\<username>\.cmds\cmds.bat

7. From now on, aliases defined in cmds.bat will be available to your Command Prompt sessions.

 

Example of useful aliases for Enthought Canopy (assuming standard installation):

@echo off

:: Canopy Aliases

doskey canopy_terminal="%USERPROFILE%\AppData\Local\Enthought\Canopy\edm\envs\User\Scripts\activate"

doskey canopy="%USERPROFILE%\AppData\Local\Enthought\Canopy\App\canopy.exe"


Using the aliases above, if you'd like to open a Canopy command prompt you can execute:

canopy_terminal

If you'd like to start the Canopy GUI from the command line you can execute:

canopy

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk