Windows redirection prevents multiple processes from simultaneously opening the same file for write access. Write operations must be serialized. This can be done with batch processing, as shown at fooobar.com/questions/402777 / .... However, I do not think this solution will help in your case.
Each trace process takes considerable time, and the output must be redirected all the time. But you want several processes to be executed at the same time, all weekends should be redirected to the same file. Even if you have to make it work, the output will alternate, and you will not be able to understand what all this means.
I recommend redirecting each tracert output to a unique file. You can include the ip address in the output file name, you can use the technique that I showed to merge the files after each process is complete.
Note that there is no need to pass the output location. Each child process has access to a trace variable, so it can easily redirect to the correct location.
contour of changes ping.bat
... set trace=..\pingRechableInfo\tracert\tracertDB ... start trace.bat %%A ...
modified trace.bat
@echo off tracert %1 >%trace%_%1.txt %= Redirect TRACERT to unique temp file =% :merge 2>nul ( %= Hide error messages inside the outer parentheses =% >>%trace%.txt ( %= Attempt stdout redirection - Fails if already locked =% type %trace%_%1.txt %= Write the temp file to the merge file =% (call ) %= Clear any error that TYPE may have generated =% ) ) || goto :merge %= Loop back and try again if stdout redirection failed =% del %trace%_%1.txt %= Delete the temporary file =% exit
A short form without comments may look like this:
@echo off tracert %1 >%trace%_%1.txt :merge 2>nul (>>%trace%.txt (type %trace%_%1.txt&(call )))||goto :merge del %trace%_%1.txt exit
source share