I need to create a batch file that trace out using tracert command some ip, and write the trace to txt files. I want it to be fast so I want to start for each trace a new command to make all the trace request start at once.
there is my ping.bat:
@echo off
set saveUnrechableLocation=..\pingUnreachableInfo\pingUnrechableInfoDB.txt
set IpListLocation=..\ipInfo\all_DB_ip.txt
set reachableLocation=..\pingRechableInfo\RechableIp\pingRechableInfoDB.txt
set trace=..\pingRechableInfo\tracert\tracertDB.txt
set numberOfPings=1
@echo pinging DB > %saveUnrechableLocation%
copy /y NUL %reachableLocation% > NUL
copy /y NUL %trace% > NUL
for /F "tokens=*" %%A in (%IpListLocation%) do (
ping -n %numberOfPings% %%A | find "TTL=" >nul
if errorlevel %numberOfPings% (
@echo %%A not rechable >> %saveUnrechableLocation%
)
if not errorlevel %numberOfPings% (
@echo %%A >> %reachableLocation%
start trace.bat %trace% %%A
)
)
and the trace.bat look like that:
@echo off
set saveLocation=%~1
set ip=%~2
tracert %ip% >> %saveLocation%
exit
the problem is that when I'm trying to use this I'm getting this problem:
the process cannot access the file because it is being used by another process
what can I do to resolve this problem? thanks!