Skip to main content
added 45 characters in body
Source Link

I have the following batch script (slightly simplified) to run a series of exe files in parallel.

SETLOCAL ENABLEDELAYEDEXPANSION

for %%a in (1 2 4 8) do ( 
  set i=%%a
  set script=calculate_V!i!.exe
  start echo started V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 
 ^& !script! ^& echo ended V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 ^& exit
)

I want to get the start and end time of the script's run, but the problem is that the delayed expansion of the second time (echo ended V!i! at !time:~0,5!) is made simultaneously with the first, so the output is (for example)

started V1 at 15:50
started V2 at 15:50
...
ended V1 at 15:50
ended V2 at 15:50
...

even though the script took 10 minutes to run.

How can I evaluate !time:~0,5! only after script runs?

Thanks

I have the following script (slightly simplified) to run a series of exe files in parallel.

for %%a in (1 2 4 8) do ( 
  set i=%%a
  set script=calculate_V!i!.exe
  start echo started V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 
 ^& !script! ^& echo ended V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 ^& exit
)

I want to get the start and end time of the script's run, but the problem is that the delayed expansion of the second time (echo ended V!i! at !time:~0,5!) is made simultaneously with the first, so the output is (for example)

started V1 at 15:50
started V2 at 15:50
...
ended V1 at 15:50
ended V2 at 15:50
...

even though the script took 10 minutes to run.

How can I evaluate !time:~0,5! only after script runs?

Thanks

I have the following batch script (slightly simplified) to run a series of exe files in parallel.

SETLOCAL ENABLEDELAYEDEXPANSION

for %%a in (1 2 4 8) do ( 
  set i=%%a
  set script=calculate_V!i!.exe
  start echo started V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 
 ^& !script! ^& echo ended V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 ^& exit
)

I want to get the start and end time of the script's run, but the problem is that the delayed expansion of the second time (echo ended V!i! at !time:~0,5!) is made simultaneously with the first, so the output is (for example)

started V1 at 15:50
started V2 at 15:50
...
ended V1 at 15:50
ended V2 at 15:50
...

even though the script took 10 minutes to run.

How can I evaluate !time:~0,5! only after script runs?

Thanks

added 174 characters in body
Source Link

I have the following script (slightly simplified) to run a series of exe files in parallel.

for %%a in (1 2 4 8) do ( 
  set i=%%a
  set script=calculate_V!i!.exe
  start echo started V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 
 ^& !script! ^& echo ended V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 ^& exit
)

I want to get the start and end time of the script's run, but the problem is that the delayed expansion of the second time (echo ended V!i! at !time:~0,5!) is made simultaneously with the first, so the output is (for example)

started V1 at 15:50
started V2 at 15:50
...
ended V1 at 15:50
ended V2 at 15:50
...

even though the script took 10 minutes to run. 

How can I eveluateevaluate !time:~0,5! only after script runs?

Thanks

I have the following script (slightly simplified) to run a series of exe files in parallel.

for %%a in (1 2 4 8) do ( 
  set i=%%a
  set script=calculate_V!i!.exe
  start echo started V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 
 ^& !script! ^& echo ended V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 ^& exit
)

I want to get the start and end time of the script's run, but the problem is that the delayed expansion of the second time (echo ended V!i! at !time:~0,5!) is made simultaneously with the first. How can I eveluate !time:~0,5! only after script runs?

Thanks

I have the following script (slightly simplified) to run a series of exe files in parallel.

for %%a in (1 2 4 8) do ( 
  set i=%%a
  set script=calculate_V!i!.exe
  start echo started V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 
 ^& !script! ^& echo ended V!i! at !time:~0,5! ^>^> log.txt ^2^>^&^1 ^& exit
)

I want to get the start and end time of the script's run, but the problem is that the delayed expansion of the second time (echo ended V!i! at !time:~0,5!) is made simultaneously with the first, so the output is (for example)

started V1 at 15:50
started V2 at 15:50
...
ended V1 at 15:50
ended V2 at 15:50
...

even though the script took 10 minutes to run. 

How can I evaluate !time:~0,5! only after script runs?

Thanks

Source Link
Loading