wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 36 forks source link

util:CloseApplication is looking for process in all sessions, not only in current session #6194

Open HamletHakobyan opened 4 years ago

HamletHakobyan commented 4 years ago

v3.11.1.2318

v16.6.2

2019

v4.7

Windows Server 2016 v1607

I have a CloseApplication action declared as follow:

(NOT Installed) AND (NOT REINSTALL) AND (NOT WIX_UPGRADE_DETECTED)

There are two users that are logged in (two active sessions). When in the first session I open Outlook and have trying to install my app in per user scenario on second session, the msi installer ask me to close Outlook inspite of that I have no opened Outlook in the current session.

I've expected to see prompt to close Outlook only if it is running in the current session. So the util shouldn't search the Outlook process system-wide but only in the current session.

HamletHakobyan commented 4 years ago

Ok.

I probably found to cause of issue. CloseApplication is searching for processes by name using CreateToolhelp32Snapshot function from Tlhelp32.h passing TH32CS_SNAPPROCESS. From Microsoft docs:

After that we sent close messages to all processes found by search. Instead, IMO, we need to filter out processes by using ProcessIdToSessionId function to close applications only from current session.

barnson commented 4 years ago

Add an option to allow per-user and per-machine packages to restrict to the current session.