All, I was provided the below code as a replacement to part of a batch file which performed some functions and then called powershell to perform arithmetic against two variables. The script outputs the result to the cmd window, but I am trying to figure out how to output to a txt file. I've tried something as simple as > output.txt
but that's not working. Any assistance is appreciated.
setlocal EnableDelayedExpansion
( set /P "num1=" & set /P "num2=" ) < test.txt
rem Adjust *two* numbers for given decimals
set "decimals=2"
for %%i in (1 2) do (
set "num%%i=!num%%i:.=!"
for /L %%d in (1,1,%decimals%) do if "!num%%i:~0,1!" equ "0" set "num%%i=!num%%i:~1!"
)
set /A "result=num1 - num2"
for /L %%d in (1,1,%decimals%) do if "!result:~%decimals%!" equ "" set "result=0!result!"
echo !result:~0,-%decimals%!.!result:~-%decimals%!