Reputation: 322
Im running it on Windows 8.1 if I run the shutdown command without the script, it works. But when I run it from this script there is some wrong syntax shown in the cmd.... thanks for help
@echo off
TITLE shutdown timer
SET /P minutes=Enter minutes till shutdown or "no" to stop running shutdowns:
IF "%minutes%" == "no" (
shutdown /a
echo shutdown aborted
) ELSE (
SET /A seconds = %minutes% * 60
shutdown /s /f /t %seconds%
)
pause
Upvotes: 0
Views: 503
Reputation: 37569
@echo off &setlocal enabledelayedexpansion
TITLE shutdown timer
SET /P "minutes=Enter minutes till shutdown or "no" to stop running shutdowns: "
IF "%minutes%" == "no" (
shutdown /a
echo shutdown aborted
) ELSE (
SET /A seconds = minutes * 60
shutdown /s /f /t !seconds!
)
Upvotes: 2
Reputation: 1250
Move the seconds out of the condition and it works:
@echo off
TITLE shutdown timer
SET /P minutes=Enter minutes till shutdown or "no" to stop running shutdowns:
SET /A seconds = %minutes% * 60
IF "%minutes%" == "no" (
shutdown /a
echo shutdown aborted
) ELSE (
shutdown /s /f /t %seconds%
)
pause
Upvotes: 1