windowsbatch-file

Multiplying Two Whole Numbers In Batch


I am trying to make a Shutdown dialogue in Batch and I have run into a slight problem. I don't like how Windows 8 asks you for the time in seconds when you would like to remote shutdown your own computer with a timer and I am trying to make a batch file that converts a given number (minutes) into seconds.

I have searched the vast majority of the interwebs and cannot find a way to multiply two whole numbers in a batch file.

Here is what I have so far:

@echo off  
echo Enter a number:  
set /p %num1%=  
echo Enter another:  
set /p %num2%=  
set /a sum1=%num1%*%num2%  
echo The total is %sum1%  
pause  

Could some kind soul please tell me where I have gone wrong?

Thanks Charlie B


Solution

  • fix to

    @echo off  
    echo Enter a number:
    set /p num1=  
    echo Enter another:
    set /p num2=
    set /a sum1="num1 * num2"
    echo The total is %sum1%  
    pause