Inno Setup - 如何显示3个选项:full |升级|卸载?

时间:2013-09-07 03:11:08

标签: upgrade inno-setup uninstall

我有一个工作的setup.exe,它从代理服务器运行“完整”和“升级”安装,只在执行setup.exe期间将用户提升为管理员。 虽然setup.exe成功创建了卸载图标,但用户没有足够的权限来执行卸载。 :( 因此,我需要将单个setup.exe提交给代理服务器,以便为用户提供单一参考点。 如何在“卸载”中添加第3个选项? 我最初的想法是欺骗[类型]部分:

[Types]
Name: "full"; Description: "Full Install"
Name: "upg"; Description: "Upgrade Only"
Name: "del"; Description: "Uninstall"

但是我编写哪个事件来启动卸载过程? InitializeSetup()太早了吗?这意味着用户尚未选择任何内容。

编辑:经过TLama的大量搜索和提示,我有一些工作。

// code snippet...
Function GetUninstallString(): String;
var
  sUnInstPath: String;
  sUnInstallString: String;
begin
  sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
  sUnInstallString := '';
  if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
    RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
  Result := sUnInstallString;
end;

Function Do_UnInstall(sUninstallString: String): Integer;
var
  ri: Integer;
begin
  // Return Values:
  //  0 -> uninstall string = empty, new install?
  //  1 -> successfully executed UnInstallString
  // -1 -> error executing UnInstallString
  Result := 0;    // Default value
  if sUnInstallString <> '' then begin
    sUnInstallString := RemoveQuotes(sUnInstallString);
    if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, ri) then
      Result := 1
    else
      Result := -1;
  end else;
end;
Function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  case CurPageID of
  wpSelectComponents:
    begin
    if WizardSetupType(False) = 'del' then  // Uninstall and exit!
      begin
        OK2Unins := True
        if Do_UnInstall(sUnins) = 1 then
          Result := False;
          //ExitProcess(0);  This fails. Prompts user with a cancel message.
          WizardForm.Close;  // This trigger CancelButtonClick() code...
      end;
    end;
  wpSelectTasks:
    begin
    end;
  wpReady:
    begin
    end;
  end;
end;

Procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
// Predefined Wizard page identifiers
// wpWelcome =            1;
// wpLicense =            2;
// wpPassword =           3;
// wpInfoBefore =         4;
// wpUserInfo =           5;
// wpSelectDir =          6;
// wpSelectComponents =   7;
// wpSelectProgramGroup = 8;
// wpSelectTasks =        9;
// wpReady =              10;
// wpPreparing =          11;
// wpInstalling =         12;
// wpInfoAfter =          13;
// wpFinished =           14;
begin
  if CurPageID = wpSelectComponents then
    Confirm := not OK2Unins;
end;

0 个答案:

没有答案