Save the below code in a batch file, something like wait.bat or whatever. Code: @echo off goto begin :: INFO: Check to see if a process is running and if so wait before launching :: a new process. After checking for a process this .bat file will wait :: for a set amount of seconds declared be the user before checking and :: looping again or moving onto the next command. :: EDIT: Change "seconds=" to "seconds=15000" to set a time of 15 seconds for :: the wait period. For 5 seconds change it to "seconds=5000" For extra :: commands you wish to add be sure to add them further below but it is :: recommended that you know what you're doing. If you need help let me :: know and I'll be happy to assist you. =) :begin :: Set wait time in seconds here set seconds= :: Set your 1st process to wait for here set program= :: Loop check echo. echo. echo Launching the %program% portable... start %program% :check cls set errorlevel= tasklist /fi "imagename eq %program%" | find /i "%program%"> NUL if /i %errorlevel% GTR 0 goto complete echo. echo The %program% process is running! echo. echo Will check again in a few seconds. echo. ping -n 1 -w %seconds% 1.1.1.1 > nul goto check :: Process complete. Start cleaning up! :complete echo. echo The %program% process has finished! echo. echo Starting next command/process... echo. :: Add here the next instruction you'd like to execute. :eof
start /wait depends on the process. - e.g. some packed exe installer with msi get return 0 instantly.
I use this for wait a program running : Code: SETLOCAL EnableExtensions SET EXE=DINO.EXE :::::::::::::::::::::::::::: ::RUN GAME :::::::::::::::::::::::::::: :ChechIfRunning FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto ProcessFound goto ProcessNotFound :ProcessFound cls ECHO. ECHO ************************************** ECHO Don't close this Windows, Game is running ECHO ************************************** ECHO. ECHO %EXE% is running timeout 1 > NUL goto ChechIfRunning :ProcessNotFound cls ECHO. ECHO ************************************** ECHO Don't close this Windows, Game is not running ECHO **************************************