BAT脚本log文件问题

这两天由于工作用到BAT脚本, 遇到了麻烦问题:写TXT log时候报错 -- “文件被线程占用,无法打开”

log文件无法打开编辑

经过长时间调试,发现在红色部分占用log,至今仍未明白。启动一个exe会一直占有log?

echo ============================ >>log.txt
echo Test started at: %date% %time% >>log.txt

::Rename the folder if it's been changed
if exist "\\guinea\QA\APXDailyRegression\vmqanubat40\IcanHelp_new" (ren "\\guinea\QA\APXDailyRegression\vmqanubat40\IcanHelp_new" "IcanHelp") >>log.txt
::start app
cd "C:\dyao\Running Projects\"
start BuildMonitor.exe >>log.txt

::pause
ping 9.9.9.9 -n 1 -w 60000 >>log.txt

:: kill app
taskkill /im BuildMonitor.exe /f /t

::Change the folder name to avoid dup running
if exist "\\guinea\QA\APXDailyRegression\vmqanubat40\IcanHelp" (ren "\\guinea\QA\APXDailyRegression\vmqanubat40\IcanHelp" "IcanHelp_new") >>log.txt

echo ============================ >>log.txt


你可能感兴趣的:(脚本)