简体   繁体   English

为什么我的关机脚本不起作用?

[英]Why does my shutdown script not work?

Im running it on Windows 8.1 if I run the shutdown command without the script, it works. 我在Windows 8.1上运行它,如果我在没有脚本的情况下运行shutdown命令,则可以正常运行。 But when I run it from this script there is some wrong syntax shown in the cmd.... thanks for help 但是,当我从此脚本运行它时,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
@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!
)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM