在我这里用管道截获 tasklist 输出,有时会出现进程不全的情况,如果你也碰到这样的问题,换用下面的代码。
tasklist /fi "imagename eq Photoshop.exe"|findstr /i "Photoshop.exe" &&taskkill /fi "imagename eq TheWorld.exe" ||echo 没有运行 Photoshop
In my place, when intercepting the output of tasklist with a pipe, sometimes the process is incomplete. If you also encounter such a problem, switch to the following code.
tasklist /fi "imagename eq Photoshop.exe"|findstr /i "Photoshop.exe" &&taskkill /fi "imagename eq TheWorld.exe" ||echo No Photoshop is running