【问题标题】:Detecting if the user selected "All Users" or "Just Me" in a Custom Action检测用户是否在自定义操作中选择了“所有用户”或“仅我”
【发布时间】:2011-01-28 19:55:06
【问题描述】:

我正在尝试检测用户在安装我的程序期间是否选择了“所有用户”或“仅我”单选。我有一个自定义操作设置,它覆盖了几种方法(OnCommit、OnBeforeInstall 等)。现在我正试图在 OnCommit 期间找出这些信息。

我已经读到我想要获取的属性是 ALLUSERS 属性,但我没有找到它在实例/本地数据中的存储位置。

有没有人知道方法?

-本

【问题讨论】:

    标签: c# action custom-action allusersprofile


    【解决方案1】:

    在这里回答我自己的问题。

    解决方案是在设置项目的属性 gui 中查看自定义操作。从那里,选择一个自定义操作允许我编辑 CustomActionData,在这种情况下我输入:

    /AllUsers=[ALLUSERS]
    

    从那里我可以通过自定义操作 CS 代码检测它是否是全用户安装:

    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;
        }
    

    希望这可以帮助那里的人:)

    【讨论】:

    • 哇,本救了我的命!无法找到如何在任何地方执行此操作。很好奇为什么我们必须设置 CustomActionData 属性才能使其工作。有没有办法直接从您的自定义操作中访问这些属性?另一个问题,你怎么知道它叫 [ALLUSERS]?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 2021-04-18
    • 2014-07-18
    • 1970-01-01
    • 2016-10-31
    • 2014-09-06
    相关资源
    最近更新 更多