【发布时间】:2016-04-01 21:20:38
【问题描述】:
我需要创建一个使用 tracert 命令一些 ip 跟踪的批处理文件,并将跟踪写入 txt 文件。我希望它很快,所以我想为每个跟踪启动一个新命令,以使所有跟踪请求立即启动。
有我的 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
)
)
trace.bat 看起来像这样:
@echo off
set saveLocation=%~1
set ip=%~2
tracert %ip% >> %saveLocation%
exit
问题是,当我尝试使用它时,我遇到了这个问题:
该进程无法访问该文件,因为它正被另一个进程使用
我可以做些什么来解决这个问题?谢谢!
【问题讨论】:
标签: file batch-file text cmd synchronization