1

I am running a batch script that starts several .exe and .R scripts and waits for them to finish before doing something else. Right now, the code to check if they have finished runs tasklist and sees if any of the .exes or Rscript.exe is still active

:LOOP

set check_if_ran=files_running.txt
tasklist | findstr "exe1.exe exe2.exe Rscript.exe" > %check_if_ran%

TIMEOUT 1 >nul

for %%F in (%check_if_ran%) do set "file_size=%%~zF"
if %file_size%0 NEQ 00  (
  echo still running 
  TIMEOUT 10 >nul
  goto :LOOP
) else (
  echo all ran
)

which worked fine in the past, but now some other independent Rscript processes might be running concurrently. Is there any way to change the name of each Rscript process, instead of them all being Rscript.exe? Or maybe some other way (save the PID of the processes I start somehow?)

Thanks

fdiogo
  • 11
  • 2
  • Type `tasklist /V` and check out the column with the `Window Title`, which could help; note that [`tasklist`](https://ss64.com/nt/tasklist.html) supports an `/FI` switch to filter for certain things like image name, window title, etc.... – aschipfl Jul 01 '19 at 13:29

0 Answers0