How to check if a process is running via a batch script

后端 未结 18 2092
一个人的身影
一个人的身影 2020-11-22 07:38

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 th

18条回答
  •  逝去的感伤
    2020-11-22 08:06

    I use PV.exe from http://www.teamcti.com/pview/prcview.htm installed in Program Files\PV with a batch file like this:

    @echo off
    PATH=%PATH%;%PROGRAMFILES%\PV;%PROGRAMFILES%\YourProgram
    PV.EXE YourProgram.exe >nul
    if ERRORLEVEL 1 goto Process_NotFound
    :Process_Found
    echo YourProgram is running
    goto END
    :Process_NotFound
    echo YourProgram is not running
    YourProgram.exe
    goto END
    :END
    

提交回复
热议问题