Loading doskey automatically with CMD

2007 Jan 31

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%\system32\cmd.exe

to

%SystemRoot%\system32\cmd.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_MACHINE\SOFTWARE\Microsoft\Command 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.

Tweet this post

1 Comment

tung

Leave a comment


About Me


Alfredo Sanchez is an internet professional focusing on the study search engines behavior in particular. Supports Free Open Source Software and currently develops applications with it using XAMPP.

Recent Entries

Close