Capture the output of a program and set environment variableTag(s): Misc Prog HowTo
This will capture the output of program or another batch file and set a given environment variable with the captured content. Only the last line is kept!
[setvar.cmd]
@Echo off for /f "delims=" %%i in ('%2') do set %1=%%i Set %1
> setvar myvar ver myvar=Microsoft Windows [Version 10.0.14393]
[realhow.cmd]
@echo Hello world from Real's HowTo
> setvar myvar realhowto myvar=Hello world from Real's HowTo