batch-file - 判断进程是否正在运行的批处理脚本
问题描述
我对批处理文件非常陌生,并且正在尝试创建一个脚本来检查进程是否正在运行并在进程是否运行时发出警报。这是我从谷歌得到的,但没有按照我想要的方式工作。
tasklist /FI "IMAGENAME eq example.exe" 2>NUL | find /I /N "example.exe">NUL if "%ERRORLEVEL%"=="0" echo Program is running
解决方案
您正试图使其复杂化。将以下内容复制到批处理文件中。也使用 findstr 代替。
tasklist /fi "imagename eq example.exe" | findstr /i "example.exe" >nul
If %errorlevel%==0 echo example.exe running.
If %errorlevel%==1 echo example.exe Not running.
推荐阅读
- swift - Xcode 10.1 协议一致性与 Xcode 10.2 beta
- php - Laravel - 将自定义样式添加到现有的 app.scss
- java - IntelliJ 会打开 java.lang 类,尽管它在调试期间没有介入其中
- javascript - 为什么 AngularJs 不在页面更改时呈现指令?
- excel - 来自 Excel 的 XML 具有多次放置的元素但不同的属性
- rest - Docker:java.net.ConnectException:连接被拒绝 - 在端口 8083 上运行的应用程序无法访问端口 3000 上的其他应用程序
- c - 如何在 getchar()!=EOF 上获取最后一个字符
- java - Spring Boot java.sql.SQLException:字段“id”没有默认值
- android - RxJava - 如何根据第二个响应重复两个 observable
- exception - 将 mule 从 3.8 升级到 3.9 后出现加密错误