Check for running application in Windows

Paul Dupuis paul at researchware.com
Fri Jun 20 12:14:09 EDT 2014


On 6/20/2014 12:09 PM, Magicgate Software - Skip Kimpel wrote:
> Good afternoon!
>
> Is there a way to check to see if there is a program currently running on a
> Windows machine?  For instance, I want to verify that a 3rd party piece of
> software is currently running (not just installed) before proceeding with
> my LC script.
>
> As usual, your comments and suggestions are always appreciated!
>
> SKIP

Use the function below to return a cr delimited list of running programs
and then filter the list to see if the app you are interested is on it
or not.

function runningPrograms
  local myList, myColPos, myNewList
  switch platform()
    case "MacOS" -- OSX Only
      put shell("ps -xcw") into myList
      put offset("COMMAND",myList) into myColPos
      repeat for each line myLine in myList
        put char myColPos to -1 of myLine & cr after myNewList
      end repeat
      filter myNewList without "(*"
      return line 2 to -1 of myNewList
      break
    case "Win32"
      set the hideConsoleWindows to true
      put shell("tasklist /V /FO "&quote&"CSV"&quote) into myList -- or
use the pv command
      set the hideConsoleWindows to false
      delete first line of myList -- remove header
      repeat for each line myLine in myList
        put item 1 of myLine & cr after myNewList -- item 1 =
"programname.exe"
      end repeat
      return myNewList
      break
    default
      return empty
  end switch
end runningPrograms





More information about the use-livecode mailing list