Temporal CMD Aliases in Windows

 

1) Create a bat file (ex. doskeys.bat). 

2) Inside, write the aliases this way:
doskey ALIAS=COMMAND

ex.:
doskey omovies=cd D:\myvideos\mymovies
doskey oseries=cd D:\myvideos\myseries

When you open doskeys.bat you'll have all those aliases avaliable. If you write omovies in the command promt you'll excecute cd D:\myvideos\mymovies.

Those aliases will not be avaliable when you close the cmd file, and I think that's better. If you make permanent aliases, maybe later you'll forget about them, and that could be problematic if in the future you use some of the alias as a filename or something and you'll have a headache trying to figure out what's wrong with your code.

Passing parameters

In case you want to open a script with an alias and include parameters, you can use $*

For example, imagine you have a node file called ndownloadlinks and your parameters are a list of urls. Without aliases you'll have to write something like this:
cd D:\myscripts\nodescripts\ndownloadlinks.js "url1.mp4" "url2.flv" "url3.avi"

Instead you can write this in the doskey.bat file:
doskey ndown=cd D:\myscripts\nodescripts\ndownloadlinks.js $*

And when you open the doskey file you have to write just this: 
ndown "url1.mp4" "url2.flv" "url3.avi"

Include it in the Taskbar

In case you want to put the bat file in your windows taskbar, just copy the cmd direct access and replace it in properties this:
C:\Windows\System32\cmd.exe 

For this:
C:\Windows\System32\cmd.exe /k D:\dirToMydoskeys\mydoskeys.bat

And then drag and drop in order to include the direct access into the bar:






Comments