如何仅在进程正在运行时继续批处理文件
我已成功地保存批处理文件直到进程结束。但是如何保存批处理文件直到进程开始?
我正在使用以下代码:
@echo off
set process_1="calc.exe"
set process_2="mmc.exe"
set ignore_result=INFO:
set no_ignore=mmc.exe
:1
for /f "usebackq" %%M in (`tasklist /nh /fi "imagename eq %process_1%"`) do if not %%M==%ignore_result% goto 1
:2
for /f "usebackq" %%N in (`tasklist /nh /fi "imagename eq %process_2%"`) do if not %%N==%no_ignore% goto 2
echo Stuff finished.......
当程序未运行时我得到的只是“信息:没有按照指定条件运行的任务”
提前感谢
S
I have successfully managed to hold a batch file until a process ends. But how do I hold a batch file until a process starts?
I am working using the following code:
@echo off
set process_1="calc.exe"
set process_2="mmc.exe"
set ignore_result=INFO:
set no_ignore=mmc.exe
:1
for /f "usebackq" %%M in (`tasklist /nh /fi "imagename eq %process_1%"`) do if not %%M==%ignore_result% goto 1
:2
for /f "usebackq" %%N in (`tasklist /nh /fi "imagename eq %process_2%"`) do if not %%N==%no_ignore% goto 2
echo Stuff finished.......
All I get when the program isn't running is "INFO: No tasks running with the specified criteria"
Thanks in advance
S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 err (2) 重定向到 stdout (1):
You could also use a
sleep
function (look for the one withping
command).Redirect the err (2) to the stdout (1):
You could also use a
sleep
function (look for the one withping
command).