0

I wrote a C# program in Visual Studio that uses the Setup & Deployment Project to create an .msi installer. The "InstallAllUsers" value is set to "True", so it'll install "Everyone" by default, but the users can change it to "Just Me" during setup.

It's just a basic installer - nothing fancy.

My question is this: after they install the program, is there a way to tell which option they chose? Is there a registry key that I can dig for that will tell me whether they chose "Everyone" or "Just Me" during install? I'm not programmatically adding any registry keys, and I can find the "Uninstall" key for my program, but I don't know if there's a value in there that will tell me.

* EDIT *

For a clearer picture:

As I make changes to my program, I increment the version numbers and give the updated .msi to the users, and they just rerun the installer. There was originally only supposed to be a couple of users, so I didn't make a complicated updater. Now there are many users, and the updater is in-the-works. For now, the current users are happy with the process - I give them a new .msi and they run it again - except for one thing: the installer doesn't "remember" their settings from the last time they ran the installer (their words, not mine). I can get the directory of their last install from the "Uninstall" regisrty value and set it with TARGETDIR, so I've got the installation path covered. But I'm trying to figure out if the user changed "Everyone" to "Just Me" the last time around.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
Kevin Herrick
  • 413
  • 1
  • 6
  • 16
  • http://stackoverflow.com/questions/2466686/detecting-if-the-user-selected-all-users-or-just-me-in-a-custom-action – MethodMan Sep 02 '16 at 22:01
  • I would suggest you use a program like RegShot (it does folder/files also) to capture the difference between an all users and a single user install. You should find something you can key off from. I have also seen the allusers flag before in the Windows Application event log for some MSIs. – Randy Schuman Sep 03 '16 at 07:56
  • For an existing scenario, PhilDW's answer is probably the most correct. In a new scenario, I would suggest either writing the value `[ALLUSERS]` to a custom registry location so you can query it later, or just removing the option for a non-ALLUSERS install (which would pre-emptively answer the question). – Michael Urman Sep 03 '16 at 19:22

3 Answers3

0

One way could be check for current logged in user in registry and see if it has the software listed in in installed software list under HKEY_CURRENT_USER\SOFTWARE\*

Rahul
  • 76,197
  • 13
  • 71
  • 125
0

There's an example here of enumerating products to find out which context they were installed in. If you know the ProductCode you can just do the MsiGetProductInfo part.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa368279(v=vs.85).aspx

There are APIs for this, so it is more advisable than guessing based on what might be in the registry.

The installation folder properties window in Visual Studio setup projects has an InstallAllUsersVisible property you should set to False. Otherwise it's going to be a nightmare when you do an upgrade with RemoveExistingProducts=True because that requires the upgrade to be in the same context as the original install. You'll find people trying to do an upgrade with All users of an installed Just me product and it will not work.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • If it were up to me, I'd set InstallAllUsersVisible to false and be done. I don't think they should be doing per-user installs of this thing, but I was overruled. Anyway, thanks for the link; it looks promising. – Kevin Herrick Sep 05 '16 at 18:02
0

I don't like per-user installs due to all the problems relating to upgrades, patching, etc... Accordingly I managed to migrate per-user installs to a per-machine during a major update install using Installshield and their built-in ISSetAllUsers custom action plus some re-sequencing of various standard actions. The description can be found here: windows Installer - uninstalling previous version when the versions differ in installation policy (per-user, per-machine)

If you want to migrate all installs to a per-machine install, you could replicate this approach using Phils suggestion to read the current installation context via your own custom action and then run this custom action in place of the ISSetAllUsers custom action that Installshield provides. Then you can follow the rest of the procedure from the link above.

Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Me neither. I default it to all users and strongly recommend to everyone that they keep it that way. As far as I know, all the user have left it alone so far. If I had my way, I wouldn't give them the option - I'd set InstallAllUsersVisible to false and be done with it. But there's a non-programmer project manager who "wants users to have the option," so I'm left trying to figure this stuff out. – Kevin Herrick Sep 05 '16 at 17:56