首先:不用这么多的临时文件。
if %a%==ar2p.exe 你的错误在这一句,%a%的值永远是2.txt最后一行的内容。
所以它很难 goto 2 除非正好ar2p.exe 排在最后一个
但是不循环的原因却不在此。
if /i "%a%"=="ar2p.exe" goto 2 这样应该就可以循环了。
find /i "ar2p.exe" c:\1.txt >c:\2.txt 这一句。
如果没有ar2p.exe,那么也就不会有2.txt文件了
如果没有2.txt那么%a%也就是空值了,
此时if %a%==ar2p.exe 就等于是if ==ar2p.exe 也就是语法错误了,当然也就退出了。
:- @echo off
- :1
- for /f "skip=2 tokens=1" %%i in ('tasklist') do (
- if /i "%%i"=="ar2p.exe" goto 2
- )
- goto 1
- :2
- shutdown -s -t 10
复制代码
|