2011-01-17 16 views
0

しばらくの間、問題が発生しました。この投稿まで、私は実際にオンラインでヘルプを依頼したことはありません。Inno SetupのTOutPutProgressWizardPageからインストールをどのように終了しますか:

私はInno Setupを使用してインストールプログラムを作成しました。多くのものをインストールします。そのうちの1つは、Java Development Kitの最新リリースです。私の問題は、JDKのインストールが存在するかどうかを確認することです。そうでない場合は、インストールを終了します。これは、私がTOutPutProgressWiazrdPageを使用してこのプロセスをユーザーに説明していない場合には、十分に簡単です。 「中止」または「終了」まですべてが正常です。これらのいずれかを打った後、インストールはうまく行きます。どうか助けていただければ幸いです。私のサンプルコードは以下の通りです:

//JDK Install 
procedure InstallJDK(); 
var 
    ErrorCode, x: Integer; 
    Return,Path: String; 
    Paths: TArrayOfString; 
begin 
    if (IsComponentSelectedLog('Prerequisites\JDK')) then 
    begin 
    GetJavaVersion(); 
    Path := GetEnv('path'); //(TNG-1463) 
     if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_LESS_THAN) and (Installed_Java_Version <> '') then 
     begin 
      if (Pos(Lowercase(JDK_ORACLE_DIR + '\jdk1.6.0_18'), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_SUN_DIR + '\jdk1.6.0_18'), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_ORACLE_DIR + '\jdk1.6.0_22'), Lowercase(Path)) <> 0)then 
      begin 
       SetFormText('Removing JDK Version: ' + Installed_Java_Version + '...', 'Preparing System...', JavaInstallationPage); 
       //Remove Java Update 1.6.0_18 
       ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{26A24AE4-039D-4CA4-87B4-2F83216018FF} /L ' + TNG_Install_Log_Dir + '\ju_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode); 
       UpdateProgressBar(PBarJavaInstall, 76); 
       //Remove JDK 1.6.0_18 
       ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{32A3A4F4-B792-11D6-A78A-00B0D0160180} /L ' + TNG_Install_Log_Dir + '\jdk_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode); 
       UpdateProgressBar(PBarJavaInstall, 80); 
       //Remove Java Update 1.6.0_22 
       ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{26A24AE4-039D-4CA4-87B4-2F83216022FF} /L ' + TNG_Install_Log_Dir + '\ju_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode); 
       UpdateProgressBar(PBarJavaInstall, 76); 
       //Remove JDK 1.6.0_22 
       ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{32A3A4F4-B792-11D6-A78A-00B0D0160220} /L ' + TNG_Install_Log_Dir + '\jdk_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode); 
       UpdateProgressBar(PBarJavaInstall, 80); 
       //Remove JDK 1.6.0_18 Directories 
       if DirExists(JDK_SUN_DIR + '\jdk1.6.0_18') then 
     begin 
      DelTree(JDK_SUN_DIR + '\jdk1.6.0_18', True, True, True); 
     end; 
       if DirExists(JDK_ORACLE_DIR + '\jdk1.6.0_18') then 
     begin 
      DelTree(JDK_ORACLE_DIR + '\jdk1.6.0_18', True, True, True); 
     end; 
       //Remove JDK 1.6.0_22 Directories 
       if DirExists(JDK_ORACLE_DIR + '\jdk1.6.0_22') then 
     begin 
      DelTree(JDK_ORACLE_DIR + '\jdk1.6.0_22', True, True, True); 
     end; 
       //Clean Up Path 
       if (Pos(Lowercase(JDK_ORACLE_DIR), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_SUN_DIR), Lowercase(Path)) <> 0) then 
       begin 
        Paths := Split(Path,';',0); 
        Path := ''; 
        for x := 0 to GetArrayLength(Paths)-1 do 
        begin 
        if (Pos(Lowercase(JDK_ORACLE_DIR), Lowercase(Paths[x])) <> 0) or (Pos(Lowercase(JDK_SUN_DIR), Lowercase(Paths[x])) <> 0) then 
        begin 
         Paths[x] := ''; 
        end; 
       end; 
       for x := 0 to GetArrayLength(Paths)-1 do 
       begin 
        if Paths[x] <> '' then 
        begin 
         if path = '' then 
         begin 
          Path := Paths[x]; 
         end 
         else 
          Path := Path + ';' + Paths[x]; 
         end; 
        end; 
       end; 
       SetxEnv('path', ExpandConstant(Path)); 
       UpdateProgressBar(PBarPostInstall1, 100); 
      end; 
      GetJavaVersion(); 
     end;  

     if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_LESS_THAN) then 
     begin 
      //Install JDK 
      Log('In Progress......Executing jdk-6u23-windows-i586.exe'); 
      UpdateProgressBar(PBarJavaInstall, 10); 
      if (CheckSupportExist('jdk-6u23-windows-i586.exe')) then 
     begin 
     Create_Dir(ExpandConstant('{sd}\apps'), JavaInstallationPage); 
     Create_Dir(JDK_ORACLE_DIR, JavaInstallationPage); 
     Create_Dir(ExpandConstant('{sd}\TNG2.0'), JavaInstallationPage); 
     Create_Dir(ExpandConstant('{sd}\TNG2.0\install'), JavaInstallationPage); 
     SetFormText('Installing JDK Version: ' + JDK_MIN_VERSION + '...', 'Preparing System...', JavaInstallationPage); 
     ShellExecLog('open', 'jdk-6u23-windows-i586.exe', '/s /v /qn" ADDLOCAL=ALL REBOOT=SUPPRESS INSTALLDIR=' + JDK_Dir + ' /L ' + TNG_Install_Log_Dir + '\jdk_' + JDK_MIN_VERSION + '_install.log"', ExpandConstant('{src}\Support\'), SW_HIDE, ewNoWait, ErrorCode); 
     UpdateProgressBarUntilProgressHasEnded('jdk-6u23-windows-i586.exe', 100, 2, JavaInstallationPage, PBarJavaInstall); 

     GetJavaVersion(); 

     if (not (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL)) then 
     begin 
      Log('Failed......' + JDK + ' ' + JDK_MIN_VERSION + ' Installation : Versions do not match.'); 
      LogError('Failed......' + JDK + ' ' + JDK_MIN_VERSION + ' Installation'); 
      ExitSetup := True; 
     end 
     else if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) then 
     begin 
      Log('Success......' + JDK + ' ' + Installed_Java_Version + ' Installed'); 
      if GetEnv('JAVA_HOME') <> JDK_Dir then 
      begin 
      ErrorCode := SetxEnv('JAVA_HOME', ExpandConstant(JDK_Dir)); 
      end; 
      //(TNG-1463) Prepend the %Java_Home%\bin so that it is the first JDK in the system's path 
      SetxEnv('path', ExpandConstant(JDK_Bin_DIR + ';' + Path)); 
     end; 
     end 
     else 
     begin 
     MsgBox('Please re-run the install after the jdk-6u23-windows-i586.exe support install is placed in the support folder.', mbInformation, MB_OK); 
       Log('User chose not to install the ' + JDK + ' ' + JDK_MIN_VERSION); 
     ExitSetup := True; 
     end; 
     end 
     else if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) then 
     begin 
      Log('Already Installed......' + JDK + ' ' + JDK_MIN_VERSION);  
     end 
     else 
     begin 
      LogError('Failed......' + JDK + ' Installation'); 
     ExitSetup := True; 
     end; 
    end; 
end; 
//Activate Setup Page 
// 
procedure JavaInstallationPage_Activate(Page: TWizardPage); 
var 
    ErrorCode: Integer; 
begin 
//Install JDK 
    InstallJDK() 
    if (ExitSetup = True) then 
    begin 
     try 
     finally 
      JavaInstallationPage.Hide; 
     end; 
    **Abort**; 
    end; 
end; 

procedure InitializeWizard(); 
begin 
    // Installation Page 
    JavaInstallationPage := CreateOutputProgressPage('JDK Installation', 'Setup is preparing the system.....'); 
    //JavaInstallationPage := CreateCustomPage(wpSQL_No_SQL_SelectSqlServer, 'POS Manufacturer Settings', 'Please select a supported manufacturer or select default'); 
    lblJavaInstallDescription1 := TLabel.Create(JavaInstallationPage); 
    with lblJavaInstallDescription1 do 
    begin 
    Top := 1; 
    Caption := ''; 
    AutoSize := True; 
    Parent := JavaInstallationPage.Surface; 
    end; 
    lblJavaInstallDescription2 := TLabel.Create(PreInstallationPage); 
    with lblJavaInstallDescription2 do 
    begin 
    Top := lblJavaInstallDescription1.Top + lblJavaInstallDescription1.Height + 5; 
    Caption := 'Installing Java Development Kit...'; 
    AutoSize := True; 
    Parent := JavaInstallationPage.Surface; 
    end; 
    PBarJavaInstall := TNewProgressBar.Create(JavaInstallationPage); 
    with PBarJavaInstall do 
    begin 
    Parent := JavaInstallationPage.Surface; 
    Width := JavaInstallationPage.SurfaceWidth; 
    Top := lblJavaInstallDescription2.Top + lblJavaInstallDescription2.Height + 3; 
    Height := 19; 
    Max := 105; 
    end; 





    JavaInstallationPage.OnActivate := @JavaInstallationPage_Activate; 
end; 

function NextButtonClick(CurPageID: Integer): Boolean; 
var 
    ErrorCode: Integer; 
    DisplayJavaInstallPage: boolean; 
    FileName: string; 
    FileLines: TArrayOfString; 

begin  
    if CurPageID = wpTomCatPortSettings then 
    begin 
     DisplayJavaInstallPage := True; 
    end; 
    if DisplayJavaInstallPage then 
    begin  
     GetJavaVersion(); 
     if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) <> VERSION_EQUAL) then 
     begin 
      JavaInstallationPage.Show; 
      try 
      finally 
       JavaInstallationPage.Hide; 
      end; 

      if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) <> VERSION_EQUAL) then 
      begin 
       **Abort**;   
      end; 
     end; 
    end;    

    if (not LocalesPopulated) and (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) and (PageCount >= 4) and isComponentSelected('XPressPOS\MWB\Locale') then 
    begin 
     // Configure MWB_Localization Settings Page 
     FileName := ExpandConstant('{tmp}\GetAllAvailableLocalesbyLocale.class'); 
     ExtractTemporaryFile(ExtractFileName(FileName)); 
     FileName := ExpandConstant('{tmp}\GetLocaleDisplayName.class'); 
     ExtractTemporaryFile(ExtractFileName(FileName)); 
     FileName := ExpandConstant('{tmp}\GetLocaleByDescription.class'); 
     ExtractTemporaryFile(ExtractFileName(FileName));  

     if SelectedLangauge <> 'es' then 
     begin 
     #if Debug == "True" 
     ShellExecLog('open', 'cmd', ExpandConstant('/K "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en US > .\Localizations.txt"'), '', SW_SHOW, ewWaitUntilTerminated, ErrorCode); 
      #else 
      ShellExecLog('open', 'cmd', ExpandConstant('/C "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en US > .\Localizations.txt"'), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); 
      #endif 
     end 
     else 
     begin 
     #if Debug == "True" 
     ShellExecLog('open', 'cmd', ExpandConstant('/K "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en MX > .\Localizations.txt"'), '', SW_SHOW, ewWaitUntilTerminated, ErrorCode); 
      #else 
      ShellExecLog('open', 'cmd', ExpandConstant('/C "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale es MX > .\Localizations.txt"'), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); 
      #endif 
     end; 

     lstLocalizations.Items.clear; 
     chkDisplayUnsupported.Checked := False; 
     if LoadStringsFromFile(ExpandConstant('{tmp}\Localizations.txt'), FileLines) then 
     begin 
      for I := 0 to GetArrayLength(FileLines)-1 do 
      begin 
       if ((FileLines[I] = 'English (United States)') or (FileLines[I] = 'Spanish (Mexico)')) then 
       begin 
        lstLocalizations.Items.Add(FileLines[I]); 
       end; 
      end; 
     end; 
    LocalesPopulated := True; 
    end; 
    Result := True;  
end; 

function BackButtonClick(CurPageID: Integer): Boolean; 
begin 
    PageCount := PageCount - 1; 
    Result := True; 
end; 
+1

「ヘイワイヤー」とはどういう意味ですか?その行動は何ですか? インストールログには何が入っていますか? – mirtheil

+0

私はこれを、InializeSetupルーチンで中止する必要のあるチェックを置くことで修正しました。アボートはそこからうまく動作します。他の場所で試して中止すると、スクリプトが正しく終了せず、予測できない例外が発生します。特に、内部から中止を呼び出すと、ファイナライズが完了します。 – TheAnomaly

答えて

0

これは、InializeSetupルーチンで中止する必要のあるチェックを置くことで解決しました。アボートはそこからうまく動作します。他の場所で試して中止すると、スクリプトが正しく終了せず、予測できない例外が発生します。特に、内部から中止を呼び出すと、ファイナライズが完了します。

+0

OPのコメントより。 – svick

関連する問題