2013-11-01 6 views
0

Windows에서 실행중인 경우 8.1 스크립트없이 shutdown 명령을 실행하면 작동합니다. 나는이 스크립트에서 실행할 때 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

그리고 정확한 오류는 무엇입니까? "Something wrong"는 적절한 오류 설명이 아닙니다. –

+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

관련 문제