3

I'm trying to detect if the user has selected the "All Users" or the "Just Me" radio during the install of my program. I have a custom action setup that overrides several methods (OnCommit, OnBeforeInstall, etc.). Right now I'm trying to find out this information during OnCommit.

I've read that the property I want to get at is the ALLUSERS property, but I haven't had any luck finding where it would be stored in instance/local data.

Does anyone know of a way to get at it?

-Ben

Ben
  • 7,692
  • 15
  • 49
  • 64

1 Answers1

4

Going to answer my own here.

The solution was to view the custom actions in the properties gui for the Setup project. From there, selecting a custom action allowed me to edit CustomActionData, in which case I put:

/AllUsers=[ALLUSERS]

From there I could detect whether it was an all-users install from the custom action CS code:

private bool IsAllUsersInstall()
    {
        // An ALLUSERS property value of 1 specifies the per-machine installation context.
        // An ALLUSERS property value of an empty string ("") specifies the per-user installation context.

        // In the custom action data, we have mapped the parameter 'AllUsers' to ALLUSERS.
        string s = base.Context.Parameters["AllUsers"];

        if (s == null)
            return true;
        else if (s == string.Empty)
            return false;
        else
            return true;
    }

Hope this helps someone out there :)

Ben
  • 7,692
  • 15
  • 49
  • 64
  • Wow Ben saved my life! Couldn't find out how to do this anywhere. Curious of why we have to set the CustomActionData property for it to work. Is there no way to access those properties directly from inside your custom action? Another question, How did you know it was called [ALLUSERS]? – dwp4ge Jan 06 '14 at 20:00