1
As a regular user in Linux this can be done via the command alias
and can be permanently stored in the .bashrc
file
As a regular user (not administrator) can I set command prompt aliases in Windows 7?
1
As a regular user in Linux this can be done via the command alias
and can be permanently stored in the .bashrc
file
As a regular user (not administrator) can I set command prompt aliases in Windows 7?
1
You can create a .cmd file and place it in a location that is by default stored in your PATH environmental setting, such as C:\windows\system32.
Give the cmd a name of your alias, edit the file and store the actual command in there. More commands of course are possible too.
For example, dr.cmd
could execute dir *.* /b
Do note, if you create a .cmd file that has the same name as an existing command, and inside you also use the same command, the cmd will call itself in an endless loop, until you press CTRL-BREAK.
If you want to pass parameters, use %1 - %9. For example:
dr.cmd
would have: dir %1 %2 %3 %4 %5 %6 %7 %8 %9
You could now use dr *.* /b
to execute dir *.* /b
0
I assume you are talking about the old Windows Command Prompt. However, its successor has, Powershell does have alias support built in. See this article for more information.
0
You can use doskey
- despite its name it's still available in Windows 10, eg:
doskey e=echo $*
This sets up a macro named e
as an alternative to echo
with the rest of the line passed to it, in the way alias e=echo
would work in Linux.
The equivalent to unalias e
would be:
doskey e=
To list all the current macros (alias
with no parameters) use:
doskey /m
Apart from this last case you could define macros for alias
and unalias
:
doskey alias=doskey $* $^^*
doskey unalias=doskey $^1=
There is a sketchy outline if you type doskey /?
, or you can search the web for more details and examples.
The command was available in XP and is still in 10, so presumably it is also there in Windows 7, though I don't have any unupgraded W7 machines to verify absolutely.
It is better to use
%*
instead of%1 %2...
then you can process up to255
arguments ;) – DavidPostill – 2016-02-19T23:13:59.027