doskey in Windows is just like alias in Linux

doskey in Windows is just like alias in Linux

Category : How-to

Get Social!

doskey on Windows is very similar to alias on Linux, it allows you to set a term which will call a command and allow you to specify default arguments. You can specify that the command showdirs could call the command dir to list the content of a folder.

You may have guessed, the above use of doskey is unlikely and has no real benefit. A better use of the command would be to turn some of the windows commands into their Linux counterparts – such as ls into dir.

Run the below command in a command prompt to alias ls to run the command dir. The $* on the end are required so that any additional arguments are also passed to the dir command.

doskey ls=dir $*

The problem with this is that all of your alias commands will be lost when you close the cmd session. To make them persist we need to create a batch file and add the entry to the windows registry.

Create a new folder in the windows directory called bin and create a new batch file inside it.

C:\>mkdir c:\windows\bin
C:\>notepad.exe c:\windows\bin\doskey.bat

Add your entries to the batch file in the below format.

@echo off
doskey ls=dir $*
doskey mv=move $*
doskey cp=copy $*
doskey cat=type $*

Next, open up regedit.exe and add an entry to the batch file to make the doskey commands permanent for each cmd session.

HKEY_CURRENT_USER\Software\Microsoft\Command Processor

Add a new String Value called AutoRun and set the absolute path in the value of c:\windows\bin\doskey.bat.

The doskey.bat file will now be executed before opening a new cmd session which will set all of your alias ready for you to use.


Visit our advertisers


Quick Poll

Are you using

Visit our advertisers