2016-12-02 201 views
0

以下過程中,集循環在我的批處理腳本打開批處理文件腳本

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收到。如果關閉,我需要使用一個循環來重新打開這兩個界面。我如何在批處理文件中編寫循環?

+1

ist it [goto](http://ss64.com/nt/goto.html),你正在尋找? – Stephan

回答

0
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) 

可能會給你你想要的結果。