对于批处理文件中的循环错误:此时出现意外

Jac*_*ski 6 batch-file

我正在尝试使用批处理文件执行以下命令:

for /f %i in (D:\random\servers.txt) DO (d:\utils\tail -60 \\%i\c$\Windows\windowsUpdate.log | d:\utils\grep "updates detected" & set tx1234=%i)
Run Code Online (Sandbox Code Playgroud)

它在命令提示符中单独调用时有效,但是只要我将它保存在批处理文件中,它就会失败并显示消息

此时出乎意料

有任何想法吗?

Loï*_*HEL 12

批处理使用%%i,而在命令行使用%i

  • 答案是正确的,但是为什么会有所不同,或者至少是导致批处理和命令行之间出现这种情况的不同之处的定义是什么? (2认同)