Solved [Beginner]Multiply variable (set /a).

May 17, 2012 at 22:13:31
Specs: Windows 7, 4x3.30GHz / 8GB
Okay I am making a batch file to start a delayed shutdown. However I am having problems with multiplying a variable by 60 (to calculate minutes into seconds).
Here is what I have.

:SHUTDOWN2
echo The system is set to shutdown in "%timer%" minutes. This is correct?
pause
echo set /a timerfix=%timer%*60
echo shutdown -s -t %timerfix%
set/p "Command=>"
if %Command%==yes goto END
if %Command%==no goto ABORT

Now all I want to know is why this isn't working. I mean I'm sure I have it all worded correctly.
Any help? Thanks in advance.


See More: [Beginner]Multiply variable (set /a).

Report •


#1
May 17, 2012 at 22:42:44
You don't show how %timer% is set. So no idea what is wrong.


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
May 17, 2012 at 23:05:44
@echo off
goto START
:START
cls
title Windows Shutdown Delay
echo Hello Wezz. Command?
set/p "Command=>"
if %Command%==shutdown goto SHUTDOWN
echo Invalid command, Type help for a list of valid commands.
pause
goto START

:SHUTDOWN
echo Shutdown loaded. Enter minutes.
set/p "timer=>"
goto SHUTDOWN2

:SHUTDOWN2
echo The system is set to shutdown in "%timer%" minutes. This is correct?
pause
echo set /a timerfix=%timer%*60
echo shutdown -s -t %timerfix%
set/p "Command=>"
if %Command%==yes goto END
if %Command%==no goto ABORT

:ABORT
echo ABORT
pause

:END
echo Shutting down.
pause
exit

Full Batch file.


Report •

#3
May 19, 2012 at 05:28:17
✔ Best Answer
I believe that
set /p command="Command=>"
and
I believe that set /p timer="timer=>"
set /a timer=%timer%

might work better. You aren't setting a variable this way

set/p "Command=>"

mike


Report •

Related Solutions


Ask Question