batch-file Bypass arithmetic limitations in batch files Using jscript


WSH/JScript is installed on every windows system since NT so using it for more complex calculations makes it pretty portable. JScript is easier for combining it with batch file :

@if (@codesection==@batch) @then
@echo off

set "expression=2*(2+3)/1000"
for /f %%# in ('cscript //nologo //e:jscript "%~f0" "%expression%"') do set 
echo %result%
:: more batch code

exit /b %errorlevel%

With this approach you can put your whole code in a single file.It is faster than using powershell. Here and here more advanced scripts can be found (which can be used as external files).