0

I am having a simple question, having simple batch script:

for /l %%x in (1, 1, 3) do start /wait c:\some.exe -verbose c:\someLog.txt del c:\someLog.txt 

after each execution file creates log, and I want to remove that log before next loop execution, execution works fine but when I add del command its having problems, it looks like log is being deleted to early.

Is there a possible way to delay del command ??

Wojciech Szabowicz
  • 3,646
  • 5
  • 43
  • 87
  • 2
    Possible duplicate of [How to run two commands in one line in Windows CMD?](http://stackoverflow.com/questions/8055371/how-to-run-two-commands-in-one-line-in-windows-cmd) – aschipfl Dec 22 '16 at 16:05

1 Answers1

3

When running multiple command I usually nest them for readability.

for /l %%x in (1, 1, 3) do (
    start /wait c:\some.exe -verbose c:\someLog.txt 
    del c:\someLog.txt 
)

You could probably do it this way as well

for /l %%x in (1, 1, 3) do (start /wait c:\some.exe -verbose c:\someLog.txt &del c:\someLog.txt)

But this does not mean that your executable is actually respecting the WAIT option. Many programs do not. I would just use the exe directly without using START at all.

Squashman
  • 13,649
  • 5
  • 27
  • 36