Window.EnumerateProcesses

table Window.EnumerateProcesses ( 

boolean TopLevel = true )

Example 1

open_processes = Window.EnumerateProcesses();

Gets the window handles and executable file paths for every process that is currently running and stores them in a table named open_processes.

Example 2

instances_of_file = 0;
file_to_check_for = "update.exe"; --have all lowercase
processes = Window.EnumerateProcesses();

for j, file_path in processes do
    file = String.SplitPath(file_path);
    if (String.Lower(file.Filename..file.Extension)) == file_to_check_for then
        instances_of_file = instances_of_file + 1;
    end
end

if instances_of_file > 1 then
    Window.Hide(Application.GetWndHandle());
    Dialog.Message("Error", "update already running: code: already running");
    Window.Close(Application.GetWndHandle(), CLOSEWND_TERMINATE);
else
    Window.Show(Application.GetWndHandle());
end

As an example, let us assume that you want to run your program, only if there is not another update.exe running on the system. To accomplish this, use the Window.EnumerateProcesses action, and check every process against the filename update.exe.

See also:  Related Actions