2013-11-01 46 views
0

如果我在没有脚本的情况下运行shutdown命令,它就在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 
+2

你得到了什么确切的错误? “出错”是没有适当的错误描述。 –

+1

您需要delayedExpansion - > http://ss64.com/nt/delayedexpansion.html – npocmaka

+0

同意,请发布语法错误文本 –

回答

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! 
) 
+0

谢谢:-)现在我看到如何使用延迟扩展在这里 – foobarbaz

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 
+0

谢谢,那工程:-) – foobarbaz

相关问题