PDA

View Full Version : Detect Active Application - not 'seeing' processes from all users



Jonathan Kay
05-28-2010, 07:43 AM
Hi,

I have a process that is started by an IIS user account - not the user running the install program. My setup script is failing to detect it's already running.

When the installer is running elevated, can it be made to 'see' the processes of all users?

Jon.

linder
05-28-2010, 08:23 AM
Jonathan,

The Windows API EnumProcessModules (PSAPI.DLL) is used to retrieve a list of all processes and then GetModuleBaseNameA to retrieve the name of the file. So if EnumProcessModules "sees" the process then the elevated running application should return "1" if the non-elevated application is active.

Just tested this. A "asInvoker" test.exe application runs non-elevated. An elevated application was able to detect the active test.exe when executed from the same profile.

But if you change the profile, e.g. run the test.exe non-elevated from the JoeUser profile, switch to the Jonathan profile and run an application elevated to check if test.exe is active in the other profile, this should result in return code 603 "Process was not currently running". It only sees the process identifier (e.g. PID: 4972), but not the process name (e.g. test.exe).

HTH,
Friedrich

linder
05-28-2010, 08:55 AM
Forgot to note:

If test.exe was launched elevated from the JoeUser Standard User profile, then of course, the IsActive detection in the Jonathan Admin profile will return "1" (application is active).

Friedrich

Jonathan Kay
05-28-2010, 10:28 AM
I've got it working now. In fact, it's fine for the IIS exe, it was a service exe that it failed for. This should have been using 'Check Service' anyway, and it's working fine now.

linder
05-28-2010, 10:40 AM
Perfect. Thanks for the good news.

Friedrich