If you've ever spent a fair amount of time in Linux, inevitably when you get on a Windows host and drop to a command line you try to run 'ls' or 'clear' habitually (causing you to want to slap youself). Well if this sounds like you, I have a solution, DosKey (and a few other tricks).
Contents
DosKey
DosKey is to Windows as Aliases are to Linux
Meaning you can create an alias for those commands that drive you nuts.
For example, say you want to create an command macro that maps 'ls' to the 'dir' command.
doskey ls=dir /w $*
The above command creates a macro so that when you miss-type 'ls' you get the dir command. Note: The $* at the end of the above command passes all command line arguments to the dir command.
Examples
doskey ls=dir /w $* doskey ll=dir $* doskey clear=cls doskey cat=type $* doskey ..=cd.. doskey cp=copy $* doskey mv=move $* doskey rm=del $* doskey grep=findstr $*
Pipe GREP doesn't work!
The grep DosKey macro above works for regular grep like usage: grep -i "SOMETHING" somefile.txt
However it doesn't work for piped input. For example, tasklist.exe | grep explorer.exe
This is a total let down, but I have a simple workaround. Just copy findstr.exe and rename it to grep.exe.
You can find findstr.exe in:
%WinDir%\System32\findstr.exe
Please note that you must have administrative privileges to do this.
Exporting DosKey Macros
doskey /macros > %USERPROFILE%\alias.doskey
How to make DosKey macros persistent
Add the following entry to your registry:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun="DosKey /MACROFILE=%USERPROFILE%\\alias.doskey