Skip to content

Commit

Permalink
Merge pull request #3948 from bclothier/FixElevationForInstaller
Browse files Browse the repository at this point in the history
Removes the restrictions on the admin elevation; add-in will be automatically registered for an admin user now.
  • Loading branch information
retailcoder committed Apr 23, 2018
2 parents d24bf63 + a1c8749 commit bcf72dd
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions Rubberduck.Deployment/InnoSetup/Installer Build Script.iss
Expand Up @@ -514,18 +514,19 @@ end;
///<remarks>
///Called after successfully installing, including via the elevated installer
///to register the VBE addin. Should be never run under elevated context
///or the registration may not work as expected.
///to register the VBE addin.
///</remarks>
procedure RegisterAddin();
begin
if not IsElevated() then
begin
RegisterAddinForIDE(HKCU32, 'Software\Microsoft\VBA\VBE\6.0\Addins', '{#AddinProgId}');
if IsWin64() then
begin
RegisterAddinForIDE(HKCU32, 'Software\Microsoft\VBA\VBE\6.0\Addins', '{#AddinProgId}');
RegisterAddinForIDE(HKCU64, 'Software\Microsoft\VBA\VBE\6.0\Addins64', '{#AddinProgId}');
end;
end
else
begin
RegisterAddinForIDE(HKCU, 'Software\Microsoft\VBA\VBE\6.0\Addins', '{#AddinProgId}');
end;
end;
///<remarks>
Expand Down Expand Up @@ -816,11 +817,10 @@ begin
ExpandConstant('{cm:RegisterAddInCaption}'),
ExpandConstant('{cm:RegisterAddInMessage}'),
ExpandConstant('{cm:RegisterAddInDescription}'),
False, False);
false, false);
RegisterAddInOptionPage.Add(ExpandConstant('{cm:RegisterAddInButtonCaption}'));
RegisterAddInOptionPage.CheckListBox.ItemEnabled[0] := not IsElevated();
RegisterAddInOptionPage.Values[0] := not IsElevated();
RegisterAddInOptionPage.Values[0] := true;
end;
///<remarks>
Expand All @@ -847,14 +847,6 @@ begin
PagesSkipped := True;
end;
// If the installer is elevated, we cannot register the addin so we must skip the
// custom page.
if (PageID = RegisterAddInOptionPage.ID) and IsElevated() then
begin
Log('RegisterAddInOptionPage skipped because we are running elevated.');
Result := true;
end;
// We don't need to show the users finished panel from the elevated installer
// if they already have the non-elevated installer running.
if (PageID = wpFinished) and HasElevateSwitch then
Expand Down Expand Up @@ -998,14 +990,14 @@ begin
// custom page we should run RegisterAdd()
else if CurPageID = RegisterAddInOptionPage.ID then
begin
if not IsElevated() and RegisterAddInOptionPage.Values[0] then
if RegisterAddInOptionPage.Values[0] then
begin
Log('Addin registration was requested and will be performed');
RegisterAddIn();
end
else
begin
Log('Addin registration was declined because either we are elevated or the user unchecked the checkbox');
Log('Addin registration was declined because the user unchecked the checkbox');
end;
end;
Expand Down

0 comments on commit bcf72dd

Please sign in to comment.