While at work, I want to use the CLI to be more productive on my Windows machine. What command, in Windows, would be a replacement for the alias command?
Answer
doskey com=a long command $*
Here $* expands to everything typed after com. For example, com Hi! would be expanded to a long command Hi!
- This not limited to the
cmd.exeshell – it works with any program that uses a Win32 console window. (For example, for Python's interactive shell, usedoskey /exefile:python.exe ...)
See doskey /? for usage. The aliases can also be added programatically; see Console Aliases for the API.
To apply aliases automatically whenever cmd.exe is launched:
Put them in a text file, in the form
alias=expansion:com=very long example command
cd=cd /d $*I keep my aliases in
%AppData%\doskey.txt.Create a batch script containing the
doskeycommand:@echo off
doskey /macrofile:"%AppData%\doskey.txt"Of course, point
/macrofileto the location you have chosen in step 1.A good name for this script is
%AppData%\autorun.cmd.In Registry, open key
HKEY_CURRENT_USER\Software\Microsoft\Command Processorand point the valueAutoRunto the script.- Run
regedit, navigate to the given key. - If a value named
AutoRundoes not exist, create it: right-click → New → String - Modify the associated data to point to wherever your autorun script from #2 is located.
- Run
No comments:
Post a Comment