Author Topic: Re: Check if process or app is running  (Read 1153 times)

DawnTreader

  • Newbie
  • *
  • Posts: 2
Re: Check if process or app is running
« on: February 03, 2022, 09:25:46 PM »
So I am trying to find out if a process is running or not. The first one I created worked great, but now I am having problems with subsequent ones.

I have this command:
Code: [Select]
Set text [MyProcess] to 'discord'
Begin Text Compare : [{PROCESSEXISTS:MyProcess}] Equals '1'
    DISABLED - Say, 'Discord Open'
    Write [Yellow] 'Discord Already Running' to log
Else
    Run application 'C:\Program Files\Discord\app-1.0.9003\Discord.exe' (maximized) - wait until it starts -set as target
    Pause 1 second
End Condition

It runs perfectly. Then I created this code.

Code: [Select]
Set text [EDDProcess] to 'EDDiscovery.exe'
Begin Text Compare : [{PROCESSEXISTS:EDDProcess}] Equals '1'
    DISABLED - Say, 'Discovery Open'
    Write [Yellow] 'ED Discovery Already Running' to log
Else
    Run application 'E:\EDDiscovery\EDDiscovery.exe' (maximized)
    Pause 1 second
End Condition

This only gives me the response of writing the message that it is already running regardless of whether it is actually running or not. Then the below code:

Code: [Select]
Set text [ICARUSProcess] to 'ICARUS Terminal.exe'
Begin Text Compare : [{PROCESSEXISTS:ICARUSProcess}] Equals '1'
    DISABLED - Say, 'ICARUS Open'
    Write [Yellow] 'ICARUS Already Running' to log
Else
    Run application 'C:\Program Files (x86)\ICARUS Terminal\ICARUS Terminal.exe'
    Pause 1 second
End Condition

Causes multiple instances of the program to run. ICARUS comes up with a dialog saying it is already running, but regardless the command is duplicating the attempt. The whole point is to start up the program only if it is not already started. I am uncertain as to why I am getting so varied results. Any help and/or suggestions would be appreciated.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Check if process or app is running
« Reply #1 on: February 03, 2022, 11:24:49 PM »
Have you checked whether your process names are correct?

The default "Processes" tab of task manager does not necessarily show process names (despite the confusing labeling by Microsoft).
The "Details" tab, however, does normally show process names.

This token internally calls standard Windows API functions, so if they're returning a process that does not appear to be running, chances are such a process is still running in the background, or if they're not returning a process that does appear to be running, chances are that that process is not running under the expected name, unless for some reason the API doesn't return that specific type of process.

Despite launching applications with a given process name, they may chain-load a different process, and drop the original, especially "web apps".

DawnTreader

  • Newbie
  • *
  • Posts: 2
Re: Check if process or app is running
« Reply #2 on: February 04, 2022, 07:43:13 PM »
Wow, the program got stuck in memory. The ED Discovery had 3 processes running. Killed all the tasks and tried the command, it worked.

The ICARUS problem seems to have been fixed as well.

Thanks!