1

我有一个有效的 setup.exe,它从代理服务器运行“完整”和“升级”安装,仅在 setup.exe 执行期间将用户提升为管理员。当 setup.exe 成功创建卸载图标时,用户没有足够的权限来执行卸载。:( 因此,向为用户提供单点参考的代理服务器提交单个 setup.exe 对我来说是可取且高效的。如何将第三个选择添加到“卸载”?我最初的想法是欺骗[类型] 部分:

[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;
4

0 回答 0