Search code examples
windowsmacroscmdaliasdoskey

Windows cmd executing multiple doskey macros with &&


In my Linux development environment I have become accustomed to building and deploying my code in one line commands, for example:

mvn clean package && ./deploy.sh localhost

I have written bash aliases that simplify this process, in my environment the above would be aliased as:

mvncp && deploy

I am now working in a Windows development environment, so I run commands in a very similar way:

mvn clean package && deploy.bat localhost

To replace my aliases I have created doskey macros. Executing a macro by itself works just fine, however when I try to execute multiple macros chained together with && all macros after the first fail to be recognized.

mvncp && deploy
<output omitted>
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.588 s
[INFO] Finished at: 2014-10-13T10:38:36-06:00
[INFO] Final Memory: 31M/209M
[INFO] ------------------------------------------------------------------------
'deploy' is not recognized as an internal or external command,
operable program or batch file.

Sometimes cmd reports the macro could not be found, other times it silently fails and %errorlevel% returns 0.

Is there any way I can execute multiple doskey macros as a single command in cmd?


Solution

  • The token you seek is $T

    From https://en.wikipedia.org/wiki/DOSKEY

    $T Command separator. Allows multiple commands in a macro.