问题
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