2013-11-01 70 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

相關問題