2017-01-26 1 views

답변

2

다른 사람이 이미 언급 한 바와 같이 (적어도) 다음과 같은 옵션이 있습니다 :

rem // Allow a key-press to abort the wait; `/T` can be omitted: 
timeout /T 5 
timeout 5 
rem // Do not allow a key-press to abort the wait: 
timeout /T 5 /NOBREAK 
rem // Suppress the message `Waiting for ? seconds, press a key to continue ...`: 
timeout /T 5 /NOBREAK > nul 

주의 사항 :

  1. timeout command을 사용하려면

    • timeout 실제로 초 카운트 따라서 대기 시간은 실제로 4 ~ 5 초 사이의 값입니다. 이것은 특히 짧은 대기 시간에 대해 성가 시거나 방해가됩니다.
    • 입력이 redirected 인 코드 블록에서 timeout을 사용할 수 없습니다. 오류 코드가 ERROR: Input redirection is not supported, exiting the process immediately. 인 즉시이를 중단하기 때문입니다. 따라서 timeout /T 5 < nul이 실패합니다.
  2. ping command 사용하려면

    rem /* The IP address 127.0.0.1 (home) always exists; 
    rem the standard ping interval is 1 second; so you need to do 
    rem one more ping attempt than you want intervals to elapse: */ 
    ping 127.0.0.1 -n 6 > nul 
    

    이 최소 대기 시간을 보장 할 수있는 신뢰할 수있는 유일한 방법입니다. 리디렉션은 문제가되지 않습니다.

0

timeout 명령을 사용해보십시오.

제한 시간/t 10

Waiting for 10 seconds, press a key to continue ...

당신은 (다른 CTRL-C 이상) 사용자의 입력을 무시 /nobreak 스위치를 사용할 수 있습니다 보여줍니다

timeout /t 30 /nobreak 

또는 당신은 그 출력을 리디렉션 할 수 있습니다 10 초를 기다리고 사용자 입력을 무시하는 빈 화면의 경우 NUL :

timeout /t 30 /nobreak > NUL 
관련 문제