What about...
for / f "tokens = *" %% a in ('echo Hello World'), set var = %% a
NOTE: use% a instead of %% a when trying on the command line, save it as %% a if used in a batch file.
Where "echo Hello World" is the command whose output you want to capture, and "var" is the name of the variable in which the output will be saved.
source share