## Monday, August 16, 2010

### Permanent Windows command-line aliases with doskey and AutoRun

On Unix, you can configure command line aliases, like this: "alias lls=ls -l". From then on, running "lls" will automatically run "ls -l", saving you a few keystrokes. The alias will go away whenever you open a command prompt; to make the alias permanent, you can save it in your .profile or .bashrc.

On Windows, you can do the same thing using the DOSKEY utility to create "macros" like this: "doskey ls=dir". Doskey macros are basically equivalent to Unix aliases (though they have different advanced features).

Automatically loading your Doskey macros is a bit more trouble, however. Doskey allows you to export a macro file, like this: "doskey /macros > my-favorite-macros.txt". You can then import your macro file like this: "doskey /macrofile=my-favorite-macros.txt".

Instead of your .profile, you'll need to configure your AutoRun registry value, in "HKEY_CURRENT_USER\Software\Microsoft\Command Processor". I have my AutoRun set to "c:\dev\autorun.bat" which runs a variety of helpful utilities.

I hope this helps!