[Window, Batch script] Wait for a Command to Finish Execution in Windows Batch File
Build 2022. 9. 13. 16:58- @참고: https://www.delftstack.com/howto/batch/batch-file-wait-for-command-to-finish/
1. Use /WAIT to Wait for a Command to Finish Execution
/B : use to stay in the same process without creating a new window.
cmd /k : used to prevent the command prompt from exiting after execution.
@echo off
echo starting first program
START /B /WAIT cmd /c "C:\Users|Aastha Gas Harda\Desktop\testfile1.bat" > output.txt
echo The first program is executed successfully.
START /B systeminfo >> output.txt
echo ALL the programs are executed successfully
cmd /k
2. Use the TIMEOUT Command to Delay the Execution
time -1 : it wil act as a puase command to wait until a key is pressed.
/nobreak : to prevent user keystrokes.
- syntax
TIMEOUT /t <time (sec)>
@echo off
echo starting first program
START /B JRuler.exe
TIMEOUT /t 30
echo The first program is executed successfully.
START /B systeminfo >> output.txt
echo All the programs are executed successfully.
cmd /k
3. Use the PAUSE Command to Pause the Execution
puase the execution of a batch file until a key is pressed.
@echo off
echo starting first program
START /B cmd /c "C:\Users\Aastha Gas Harda\Desktop\testfile1.bat" > output.txt
echo The first program is executed successfully.
PAUSE
START /B systeminfo >> output.txt
echo All the programs are executed successfully
cmd /k
'Build' 카테고리의 다른 글
[Gradle] compile vs implementation (0) | 2022.03.14 |
---|