2

I've created a C# app for Windows 10. It is installed via an MSI generated with WIX. When it is installed for one user on a machine, though, through no intention of my own, it is not installed for other users on the same machine.

This behavior is actually fine (though unplanned), but the problem comes on uninstall.

If two users install it, and only user-a uninstalls it, it gets fully uninstalled for user-a, and becomes broken for user-b. User-b will still see it listed in "Apps & Features" in the Settings app, but all files in "C:\Program Files (x86)" will have been removed, so it will not run at all.

The solution I'm going for is this. When user-a uninstalls it, all that should happen (if user-b also has it installed) is the listing should be removed from the Settings app under "Apps & Features" and also from the Control Panel under "Programs & Features". No files should be removed from "C:\Program Files (x86)".

This should be possible, since, when only installed by one user in the first place, the files at "C:\Program Files (x86)" are all there for both users, but only the user who installed the app sees it listed in Settings or in the Control Panel.

My question is, how do I only remove the links to the app from Settings > "Apps & Features" and also from Control Panel > "Programs & Features" for just one user?

I've seen that there are ways to remove the listing for both users without uninstalling the app, such as altering/deleting the registry entry at:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

...but that is not my goal. I just want to be able to remove the listings for only one user, while keeping the listings for all other users.

If I knew how the listing could be there for one user and not for another, I could probably figure out how to make my app cause that to happen. But I'm not sure what populates these two program lists in the first place, or what would make them different for different users.

I hope this made sense! Thanks in advance for any assistance you can offer!

DBA108642
  • 1,995
  • 1
  • 18
  • 55
gcdev
  • 1,406
  • 3
  • 17
  • 30

1 Answers1

1

Set Package/@InstallScope="perMachine". That ensures there's one copy and it's shared by all users on the machine.

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
  • Thank for this advice! It really is ideal though if individual users can install and uninstall on their own. I'll consider your suggestion though if I can't find a way to achieve my goal! – gcdev Nov 19 '19 at 18:43
  • If you want per-user installations, they can't go to a shared location like Program Files. – Bob Arnson Nov 19 '19 at 19:56
  • Um... that's where WIX put them. Where should they go if not there? – gcdev Nov 19 '19 at 20:04
  • And how would I get WIX to put them where they ought to be? And why did WIX, apparently by default, install them in a shared folder yet only list them in Settings for one user? And finally, how did WIX do that (cause that's what my original question really was)? – gcdev Nov 19 '19 at 21:57
  • Windows Installer (WiX is just the build tool) supports both per-machine and per-user packages. The registration (including P&F/ARP) is distinct from where files go. – Bob Arnson Nov 20 '19 at 02:43
  • I'm going to mark this answer as my solution even though it technically isn't, but it pointed me in the right direction. I set and set the install directory to "AppDataFolder". That made the install a per-user install and resolved my problems on uninstall. – gcdev Dec 13 '19 at 16:33