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

后端 未结 18 2093
一个人的身影
一个人的身影 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:12

    You should check the parent process name, see The Code Project article about a .NET based solution**.

    A non-programmatic way to check:

    1. Launch Cmd.exe
    2. Launch an application (for instance, c:\windows\notepad.exe)
    3. Check properties of the Notepad.exe process in Process Explorer
    4. Check for parent process (This shows cmd.exe)

    The same can be checked by getting the parent process name.

提交回复
热议问题