Create command-line alias in windows

Shivam Gupta
2 min readAug 21, 2019

Many time we need to use the same commands all-time in the terminal example:

  1. change directory to a long path like-

2. Open your server ssh terminal every time you need to run ssh commands like —

We can set an alias to quickly execute to a particular command like-

set macros(alias) using DOSKEY command

Run: wd so it will locate to desired path

But as we close the terminal so it would not work any more. How to make it permanent.

  1. Create a batch file here we can write Doshkey commands
doskey.bat

2. Copy command prompt shortcut to desktop/ any location you want -

search — command prompt
copy shortcut and paste to desktop

3. Rename it to any name — alias

Shortcut in desktop

4. now provide a path of the batch file to this shortcut by —

a. right click on icon select properties -> shortcut

b. In target give space and add

/k C:\Users\user\Desktop\working_dir\doskey.bat

put path of .bat file

Done. Now you can easily access your all alias by opening this shortcut

like —

Now alias — wd, stg will work

You can now put any number of alias in .bat file

Please give a clap if you like this post. Also, write in the comment section.

--

--

Shivam Gupta

Full Stack Engineer (Web/App) working on different JS Technologies & frameworks— Angular, Node, Typescript, Ionic, Firebase, AWS, ElK...Love to write cool stuff