One way is:
application arg0 arg1 > temp.txt
set /p VAR=<temp.txt
Another is:
for /f %%i in ('application arg0 arg1') do set VAR=%%i
Note that the first %
in %%i
is used to escape the %
after it and is needed when using the above code in a batch file rather than on the command line. Imagine, your test.bat
has something like:
for /f %%i in ('c:cygwin64indate.exe +"%%Y%%m%%d%%H%%M%%S"') do set datetime=%%i
echo %datetime%
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…