Batch program to to check if process exists

前端 未结 5 1986
一整个雨季
一整个雨季 2020-12-02 14:55

I want a batch program, which will check if the process notepad.exe exists.

if notepad.exe exists, it will end the process

5条回答
  •  旧巷少年郎
    2020-12-02 15:08

    Try this:

    @echo off
    set run=
    tasklist /fi "imagename eq notepad.exe" | find ":" > nul
    if errorlevel 1 set run=yes
    if "%run%"=="yes" echo notepad is running
    if "%run%"=="" echo notepad is not running
    pause
    

提交回复
热议问题