Inno Setup: .NET Framework 설치, 시스템 재부팅 후 설치 계속 (Inno Setup: Install .NET framework, reboot the system and continue installation)


문제 설명

Inno Setup: .NET Framework 설치, 시스템 재부팅 후 설치 계속 (Inno Setup: Install .NET framework, reboot the system and continue installation)

일부 시스템 필수 구성 요소를 설치해야 하며 완료한 후 시스템을 다시 시작해야 합니다. 그러면 중단한 부분부터 설치를 계속해야 합니다. 전제 조건은 .NET 프레임워크와 Windows 업데이트입니다.

[Code] 섹션:

const
  (*** Customize the following to your own name. ***)
  RunOnceName = 'My Program Setup restart';

  QuitMessageReboot = 'Os requisitos para a instalação do sistema não estão completos. Precisamos reiniciar seu computador para continuar a instalação do sistema.'#13#13'Depois de reiniciar o seu computador, o setup irá continuar a instalação após o primeiro login com uma conta administradora.';
  QuitMessageError = 'Error. Cannot continue.';

var
  Restarted: Boolean;
  ResultCode: Integer;

function InitializeSetup(): Boolean;
begin
  Restarted := ExpandConstant('{param:restart|0}') = '1';

  if not Restarted then begin
    Result := not RegValueExists(HKLM, 'Software\Microsoft\Windows\CurrentVersion\RunOnce', RunOnceName);
    if not Result then
      MsgBox(QuitMessageReboot, mbError, mb_Ok);
  end else
    Result := True;
end;

function DetectAndInstallPrerequisites: Boolean;
begin
  (*** Place your prerequisite detection and installation code below. ***)
  (*** Return False if missing prerequisites were detected but their installation failed, else return True. ***)

  if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/q /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  begin
    MsgBox(QuitMessageReboot + IntToStr(ResultCode) + '....',
      mbError, MB_OK);    
  end;

  Result := True;
end;

function Quote(const S: String): String;
begin
  Result := '"' + S + '"';
end;

function AddParam(const S, P, V: String): String;
begin
  if V <> '""' then
    Result := S + ' /' + P + '=' + V;
end;

function AddSimpleParam(const S, P: String): String;
begin
 Result := S + ' /' + P;
end;

procedure CreateRunOnceEntry;
var
  RunOnceData: String;
begin
  RunOnceData := Quote(ExpandConstant('{srcexe}')) + ' /restart=1';
  RunOnceData := AddParam(RunOnceData, 'LANG', ExpandConstant('{language}'));
  RunOnceData := AddParam(RunOnceData, 'DIR', Quote(WizardDirValue));
  RunOnceData := AddParam(RunOnceData, 'GROUP', Quote(WizardGroupValue));
  if WizardNoIcons then
    RunOnceData := AddSimpleParam(RunOnceData, 'NOICONS');
  RunOnceData := AddParam(RunOnceData, 'TYPE', Quote(WizardSetupType(False)));
  RunOnceData := AddParam(RunOnceData, 'COMPONENTS', Quote(WizardSelectedComponents(False)));
  RunOnceData := AddParam(RunOnceData, 'TASKS', Quote(WizardSelectedTasks(False)));

  (*** Place any custom user selection you want to remember below. ***)

  //<your code here>

  RegWriteStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\RunOnce', RunOnceName, RunOnceData);
end;

function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  ChecksumBefore, ChecksumAfter: String;
begin
  ChecksumBefore := MakePendingFileRenameOperationsChecksum;
  if DetectAndInstallPrerequisites then begin
    ChecksumAfter := MakePendingFileRenameOperationsChecksum;
    if ChecksumBefore <> ChecksumAfter then begin
      CreateRunOnceEntry;
      NeedsRestart := True;
      Result := QuitMessageReboot;
    end;
  end else
    Result := QuitMessageError;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := Restarted;
end;

반환은 QuitMessageReboot<변수입니다. /code>는 값이 2ResultCode와 연결됩니다.

dotNetFx40_Full_x86_x64.exe는 다음에 의해 설치됩니다.

[Files]
;.Net Framework
Source: "Dependencias\.Net Framework\dotNetFx40_Full_x86_x64.exe"; DestDir: "{tmp}"; \
    Flags: deleteafterinstall

참조 솔루션

방법 1:

As the name says, the PrepareToInstall event happens before the installation. The files are not installed yet. So the Exec obviously fails, as there's nothing to execute.

You can extract the dotNetFx40_Full_x86_x64.exe from the code using ExtractTemporaryFile function:

[Files]
Source: "...\dotNetFx40_Full_x86_x64.exe"; Flags: dontcopy

[Code]
function DetectAndInstallPrerequisites: Boolean;
var
  ResultCode: Integer;
  Success: Boolean;
begin
  ExtractTemporaryFile('dotNetFx40_Full_x86_x64.exe');

  WizardForm.PreparingLabel.Caption := 'Installing .NET framework...';
  WizardForm.PreparingLabel.Visible := True;
  try
    Success :=
      Exec(
        ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/q /norestart', '',
        SW_SHOW, ewWaitUntilTerminated, ResultCode);
  finally
    WizardForm.PreparingLabel.Caption := '';
    WizardForm.PreparingLabel.Visible := False;
  end;

  if not Success then
  ...
end;

Make sure you add the dontcopy flag to the [Files] section entry.

(by Luiz NegriniMartin Prikryl)

참조 문서

  1. Inno Setup: Install .NET framework, reboot the system and continue installation (CC BY‑SA 2.5/3.0/4.0)

#pascalscript #inno-setup






관련 질문

Inno Setup의 WizardForm 페이지에서 레이블 텍스트 변경 (Changing label texts on WizardForm page in Inno Setup)

파스칼스크립트 디버깅 중에 양식 양식을 일시 중단할 수 있습니까? (Can a forms modality be suspended during pascalscript debugging?)

Inno Setup: .NET Framework 설치, 시스템 재부팅 후 설치 계속 (Inno Setup: Install .NET framework, reboot the system and continue installation)

Inno Setup - [code] 내부의 기본 경로 정의 (Inno Setup - Defining a default path inside [code])

파스칼스크립트에 DLL 함수 등록하기 (Registering DLL-Functions in Pascalscript)

HelpNDoc 파스칼 스크립트는 구조를 지원합니까? (Does HelpNDoc Pascal Script support structures?)

하위 설치 다운로드 및 실행 - Inno Download Plugin 다운로드 중에 진행률 표시줄이 이동하지 않음 (Download and run sub install - Inno Download Plugin progress bar does not move during download)

TBitmapImage는 Inno Setup 6에서 크기 조정된 디스플레이의 크기보다 크게 렌더링됩니다. (TBitmapImage is rendered larger than its size on scaled display in Inno Setup 6)

Inno Setup에서 필요할 때 시작 화면을 표시하지 않으려면 어떻게 해야 합니까? (How can I prevent showing the splash screen when I need it in Inno Setup?)

Inno Setup을 사용하여 현재 날짜를 레지스트리에 바이너리 형식으로 저장 (Storing the current date to the registry in binary format with Inno Setup)

Inno Setup 설치 프로그램 이전의 시작 화면에 이미지가 표시되지 않음 (Image on a splash screen before Inno Setup installer does not display)

Inno Setup 단어 완성이 전혀 작동하지 않습니다 (Inno Setup word completion doesn't work at all)







코멘트