Detecting if the user selected “All Users” or “Just Me” in a Custom Action

こ雲淡風輕ζ 提交于 2019-12-10 21:43:54

问题


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


回答1:


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 :)



来源:https://stackoverflow.com/questions/2466686/detecting-if-the-user-selected-all-users-or-just-me-in-a-custom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!