0

如果我在没有脚本的情况下运行关机命令,我在 Windows 8.1 上运行它,它可以工作。但是当我从这个脚本运行它时,cmd中显示了一些错误的语法......谢谢你的帮助

@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
4

2 回答 2

2
@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!
)
于 2013-11-01T18:46:47.653 回答
1

将秒数移出条件,它可以工作:

@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
于 2013-11-01T17:50:17.740 回答