While Linux has a simple command alias, this will require more work in windows.
We will firstly use the doskey command :
doskey ls=dir $* |
This command will create an alias ls that will execute the dir command.
The variable $* allow us to pass all of the arguments entered after the alias.
We can now use ls command instead of dir. Works very well, but alias won’t be saved when we quit 🙁
We will now set multiple commands in an external file :
cmd_aliases.txt
ls=dir $* ps=tasklist $* clear=cls |
And execute :
doskey /macrofile=c:\bin\cmd_aliases.txt |
Good, but we still loose our aliases when we quit.
We’ll have to put this command in an autorun script called when cmd.exe launches.
cmd_autorun.cmd
@echo off cls doskey /macrofile=c:\bin\cmd_aliases.txt |
And a last script to install our autorun in registry :
cmd_autorun_install.cmd
reg add "hkcu\software\microsoft\command processor" /v Autorun /t reg_sz /d c:\bin\cmd_autorun.cmd |
Execute cmd_autorun_install.cmd (double click)
That’s ok !
Sources :
https://users.cs.jmu.edu/bernstdh/web/common/help/ntshell.php
http://superuser.com/questions/49170/create-an-alias-in-windows-xp/115259#115259
Pingback: Generate xsd from xml with trang « DisplayObject
How sad to have been working for years in Linux and now in my new work I must use Windows again ¬¬ just to find out it has no aliases. Thanks to you this workaround it’s quite helpful =) I’ll still try to get the authorization to use Linux (I did it myself, but I was warned this can’t be done) I need to behave =( Thanks =)
Thanks for this!
One wonders why MS didn’t set up an Autorun file by default, so that we didn’t have to go to the registry to do it.
You genius! Thats a .bashrc File for Windows. Pretty cool and thank you! Ah, if you looking for the linux toolchain without having installed Cygwin, try UnxUtils.
Pingback: Don’t type php app/console to access the console anymore! [Symfony2] | Natanael Oliva
Thanks for this Jonas!
I’m working on a symfony project (normally on my mac), but today I’m stuck with a windows laptop.
This went a long way toward not needing to change my normal workflow (almost as good as installing cygwin – which may have been my next move if not for this post).
Thanks so much for sharing!
Sincerely,
Jay
Pingback: Créer des alias permanent sous Windows | Lab Arnaud Huc
copy dir.exe ls.exe
This is awesome.
I’ve been in the Linux world for over 15 years and just coming back into Windows to see how things have changed.
I’ve gone one step further and aliased reg-add to the reg add command you have on here, so I can update on the fly.