如何检查进程是否正在通过批处理脚本运行 [英] How to check if a process is running via a batch script
本文介绍了如何检查进程是否正在通过批处理脚本运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查应用程序是否正在从批处理(井cmd)文件运行?
How can I check if an application is running from a batch (well cmd) file?
如果程序已在运行,我需要不启动另一个实例。 (我无法更改应用程序,使其成为单实例。)
I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.)
此外,应用程序可以作为任何用户运行。
Also the application could be running as any user.
推荐答案
我想到的另一种可能性是,使用 grep ,is:
Another possibility I came up with, inspired by using grep, is:
tasklist /FI "IMAGENAME eq myapp.exe" 2>NUL | find /I /N "myapp.exe">NUL
if "%ERRORLEVEL%"=="0" echo Programm is running
它不需要保存一个额外的文件,所以我喜欢这种方法。
It doesn't need to save an extra file, so I prefer this method.
这篇关于如何检查进程是否正在通过批处理脚本运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文