Evaluating expressions in windows batch script

Solution 1:

This way:

Set /a 4+2

Or to store it in a variable for later:

Set /a foo = 4+2
echo %foo%

And to answer your last line, there is a good chance that you may be pushing batch a little further than intended. The Windows Script host is available on your machine and would allow VBScript or JScript. Also if you are going to learn something new anyway I would highly suggest using Powershell instead.

Solution 2:

set Result=0

echo start %Result%

echo Adding 4 and 2
set /a Result= 4+2

echo finish %result%

pause >nul