cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Budetov
Level 3

Run command with output redirection and check result

Hello all!

In order to check whether process with given name is running I would like to run following command using InstallScript:
wmic process list brief | find /i "MyApp.exe"


I would like to check it's result afterwards (0 or 1).
What method with what options should I use? (LaunchApp, LaunchAppAndWait etc.).
I've tried different combinations and no one works as expected. I suppose the problem is in using "|" output redirection operator.
Labels (1)
0 Kudos
(1) Reply
Budetov
Level 3

Here is the function I've gone to. Checks whether process is running using WMI.
function BOOL ProcessRunningWMI(szAppName)
STRING szCmdLine;
begin
szCmdLine = "/c \"wmic process list brief | find /i \""+szAppName+"\"\"";
if (LaunchApplication("cmd",szCmdLine,"",SW_HIDE,2000,
LAAW_OPTION_WAIT | LAAW_OPTION_USE_SHELLEXECUTE ) < ISERR_SUCCESS) then
return FALSE;
endif;
return LAAW_PARAMETERS.nLaunchResult = 0;
end;
0 Kudos