How to set aliases for the Windows command line

In this article, we will learn a useful way to determine aliases (aliases) for the Windows command line. By following the steps below, you will be able to specify any aIias you wish, thereby extending the default of cmd.exe saving time and effort of pointless typing.

The method described below works on all modern versions of Windows, including Windows 10, Windows 8.1, Windows 8, and Windows 7.

aliases 6

There is the command DOSKEY which is available at the Windows command prompt.

Using doskey, it is possible to set a nickname for a new or an existing console command.
For example, almost all users are familiar with the command “cd”Used to change the current directory on the command line.

If the desired directory is located on another drive, you should use the "/ D" switch with the cd command or type the drive letter at the command prompt.
For example:

d: cd Documents

ή

cd / dd: \ Documents

Using the doskey command, you can save typing time and set an alias that will allow you to override the requirement to write the drive letter and the "/ d" switch. For example:

DOSKEY cd = cd / D $ *

The following are some special codes for the doskey command:
$ T - command line separator. It allows multiple commands in one macro.
$ 1- $ 9 - batch parameters. Equals% 1 -% 9 in batch programs.
$ * - Symbol replaced by any type after the macro name on the command line. We used it in the example above.

If you give the doskey /? at the command prompt you will get a little help on how the doskey command is written

aliases 8

Now, we can compare them without the above aIias and with aIias.
Without the alias, the cd command will not change the disk you are already in

aliases 1

With the alias created with the doskey command, the command line will change the active disk and the current folder automatically:

aliases 2

This is a very useful command that saves us from overused typing.

Using doskey, it is possible to define your own aliases. For example, you can create the LS alias for the dir command to use a common command for it of directories whether you work on Windows or Linux. As you already know, the LS command is the default Linux command to see a list of our files (the equivalent of cd for Windows).

DOSKEY ls = dir 

Generally set aliases at the Windows command line

The with aliases is that they only work for the command prompt window you've assigned them to. To avoid this issue, you can create a new shortcut for cmd.exe or even modify the default one. You should add the following parameters to the new shortcut after cmd.exe:

cmd.exe /kc:\iguru.gr\aliases.cmd

Here the file c: \ iguru.gr \ aΙiases.cmd is a regular batch file containing your appropriate DOSKEY commands.

 

In addition to the command line, Windows also allows you to specify your own Aliases for the "Run" window.

iGuRu.gr The Best Technology Site in Greecefgns

every publication, directly to your inbox

Join the 2.087 registrants.

Written by Dimitris

Dimitris hates on Mondays .....

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).