Loading doskey automatically with CMD

Most of the time i do work with the linux shell, so most of the time i will be using ls to display files the current folder. However, in windows the command to display files is dir. i would always interpret cmd as a linux shell.
Back with the good old days, we could use doskey to assign shortcuts to DOS commands. So, we could just assign ls to its windows equivalent like this:

C:> doskey ls=dir

Now, whenever we type ls, dir command is executed. We could also do that in Windows XP Command prompt, but the problem is after you have closed the window the doskey is also removed as well and we have to type it again every time we would run cmd.
There is actually a work around with that, we could modify our cmd shortcut in the start menu to add the doskey instructions there so that everytime the cmd is loaded the extra line is also executed as well.
cmd-shortcut.jpg cmd-properties.jpg
i have modified my shortcut target from


%SystemRoot%system32cmd.exe

to


%SystemRoot%system32cmd.exe /k doskey ls=dir

the /k makes the window stay after the doskey is executed. For more additional options about cmd you can issue the command


C:> cmd /?

here are a few common options:
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
/S Modifies the treatment of string after /C or /K
/Q Turns echo off
/D Disable execution of AutoRun commands from registry
Alternatively, you could also change the value of your registry at

HKEY_LOCAL_MACHINESOFTWAREMicrosoftCommand Processor

to
Value name: AutoRun
Value data: doskey ls=dir
Actually, its better to use the registry option because after adding the code to the shortcut properties; the code completion for the command prompt no longer works.

2 Comments
  1. tung

  2. Nice Tip!

    I’ve been wanting to do this for some time.

    Still works on Windows 7.

    Mark

Leave a Reply