集循环在我的批处理脚本打开批处理文件脚本
问题描述:
以下过程中,集循环在我的批处理脚本打开批处理文件脚本
tasklist /nh /fi "imagename eq udp-receiver.exe" | find /i "udp-receiver.exe" > 2 || (start c:\udp-receiver.exe -f 1.zip --nosync --interface 00-00-ab-00-00-CD --portbase 989)
(start d:udp-receiver.exe -f 1.zip --nosync --interface 00-00-ab-00-00-CF --portbase 989)
开2会话UDP收到。如果关闭,我需要使用一个循环来重新打开这两个界面。我如何在批处理文件中编写循环?
答
find /i "udp-receiver.exe" > 2
不正确。 >
是重定向操作符(“find”的输出将被重定向到文件“2”)。
如果要计算包含字符串的行数,则需要将/c
开关应用于find
命令。
for /f %%a in ('
tasklist /nh /fi "imagename eq udp-receiver.exe" ^| find /i /c "udp-receiver.exe"'
) do if %%a gtr 2 (echo more than 2) else (echo 2 or fewer)
可能会给你你想要的结果。
ist it [goto](http://ss64.com/nt/goto.html),你正在寻找? – Stephan