A. Some programs return values to the command line and it may be you want these in a variable so they can be viewed/queried by other processes.

The easiest way to put the result into an environment variable is to trap it in a FOR statement.

For /f "Tokens=*" %i in ('command') do set

For example:

C:\>For /f "Tokens=*" %i in ('ver') do set NTVersion="%i"

C:\>set NTVersion="Windows NT Version 4.0 "

C:\>echo %NTVersion%
"Windows NT Version 4.0 "

If you place the command in a batch file you require two % in front of i, e.g.

For /f "Tokens=*" %%i in ('ver') do set NTVersion="%%i"