bat 判断某个路径exe 是否运行
时间: 2023-08-01 13:09:55 浏览: 269
可以使用 `tasklist` 命令来查看指定进程是否在运行。具体做法如下:
```batch
@echo off
set "exe_path=C:\Windows\System32\notepad.exe"
tasklist | findstr /i "%exe_path%" > nul
if %errorlevel% equ 0 (
echo %exe_path% is running.
) else (
echo %exe_path% is not running.
)
```
其中,`exe_path` 变量为需要检查的可执行文件路径。通过 `tasklist` 命令查看所有正在运行的进程,然后通过 `findstr` 命令过滤出包含 `exe_path` 的进程,如果找到则返回 `0`,否则返回 `1`。根据返回值判断进程是否在运行。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)