Is it possible to recall an alias with DOSKEY? Simple example .. I wish to do something like that:
DOSKEY a=someCommand
DOSKEY b=someOtherCommand
DOSKEY c=andAThirdCommand
:: How to do this? -> DOSKEY all=a+b+c
I already know that I can do this by writing this:
DOSKEY all=someCommand ^& someOtherCommand ^& andAThirdCommand
but in the sense of reusing stuff I'd like to reuse my defined aliases from above. Is it possible like I desire?
Thanks!
PS: Saw this here, but it's not a satisfying answer. It seems that it won't work though. :(
Good question, hard to answer... However, I can suggest a workaround with a simple batch script(s).
Suppose we have defined
doskey a=commandAanddoskey a=commandBanddoskey c=commandCmacros.Static approach: let's name our script e.g.
dem(define macro) and place it somewhere in yourpath. Thendem acb a c bshould define a new macroacb(ready to further use) as follows:doskey acb=commandA $T commandC $T commandB. That script could be established by a little adaptation from the scriptdskprovided (hint: instead of launching a macro text, constitute the text for new macro, but be aware of another escaping).Dynamic approach: let's name our script e.g.
dsk(doskey) and place it somewhere in yourpath. Thendsk a b cshould call macrosa,bandcin that sequence. Number of parameters (macro names) passed to script is not limited. The script works well with very simply defined macros, but%percent sign use like indoskey a=echo %variable%macro and/or evenforloops like indoskey a=for /F "tokens=*" %G in ('dir /b /s *.txt') do @echo %G;$Tconcatenated commands in a macro (equivalent to&in a batch file) likedoskey a=dir $T set; done by replacing$Twith&(in rare cases does not suffice, then need to split and perform commands separately).Known issues and/or restrictions (impossible to resolve without knowing more about real structure of macros used); the
dskscriptforloop could bring problems with%%parametervariable; vetoed to use in a macro:%%{(outer loop) and%%?%%@(inner loop)doskey a=dir ^> somefile;^&concatenated commands in a macro (but allowsdoskeyintrinsic$Tconcatenation);.bator.cmdscripts (needscall %xitem%instead of%xitem%in the:doItemprocedure (cca 50th line);The script
dskis as follows:With next scenario:
and
dsk y b a x ncall gives next output:The script is rather verbose for debugging purposes (and variable
CheckOnlyas well, with values1= only echo commands,0= echo and execute commands in a macro).