5

我有一个 inno 设置代码,它安装 python。它工作正常,我得到了setup.exe文件,其中包含 python 的设置文件。但是当我尝试使用该设置文件安装python时,它没有工作。那是因为安装文件正在寻找文件部分中指定的python文件,如果是这样我该如何更改代码以便setup.exe中的python将被使用。此外,每次我安装设置时,设置都会创建一个默认应用程序。我尝试了属性DisableDirPage=yes,但它没有用。任何机构都可以提出一些解决方案。

             #define MyAppName "My Program"
             #define MyAppVersion "1.5"



                    [Setup]
           AppId={{BD59E856-F194-4E05-A93B-89089F3E3E9D}
           AppName={#MyAppName}
           AppVersion={#MyAppVersion}
          ;AppVerName={#MyAppName} {#MyAppVersion}
          ;AppPublisher={#MyAppPublisher}
          ;AppPublisherURL={#MyAppURL}
          ;AppSupportURL={#MyAppURL}
           ;AppUpdatesURL={#MyAppURL}
           DefaultDirName={pf}\{#MyAppName}
           DefaultGroupName={#MyAppName}
           OutputBaseFilename=setup
           Compression=lzma
           SolidCompression=yes
           DisableDirPage=yes


          [Files]
             Source: "H:\python-2.7.5.msi"; DestDir: "{app}"; Flags: ignoreversion




            [code]
             #define MinJRE "1.6"
            #define WebJRE "H:\python-2.7.5.msi"

           function InitializeSetup(): Boolean;
           var
          ErrorCode: Integer;
         PythonInstalled : Boolean;
          Result1 : Boolean;
          begin
              PythonInstalled :=                      RegKeyExists(HKLM,'SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath');
          if PythonInstalled then
            begin
          MsgBox('installed', mbInformation, MB_OK);
           end
                else
            begin

           Result1 := MsgBox('2222222222222222This tool requires python Runtime Environment  to run.  Do you want to install it now?',
            mbConfirmation, MB_YESNO) = idYes;
          if Result1 = false then
             begin    
             Result:=false;
             end 
         else
            begin

             MsgBox('not installed', mbInformation, MB_OK);
              Result:=true;
              ShellExec('',
               '{#WebJRE}',
              '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
             end;
                  end;
                end;
4

1 回答 1

5

正如 Tlama 所说,对您的脚本进行了一些更改。在我身边工作正常,更改了文件部分条目并使用 Exec 而不是 ShellExec ...

将 python-2.7.5.amd64.msi 替换为 python-2.7.5.msi 并将 D:\ 替换为 H:\

#define MyAppName "My Program"
#define MyAppVersion "1.5"

[Setup]
AppId={{BD59E856-F194-4E05-A93B-89089F3E3E9D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
DisableDirPage=yes

[Files]
Source: "D:\python-2.7.5.amd64.msi"; Flags: dontcopy

[code]
#define MinJRE "1.6"

function InitializeSetup: Boolean;
var
  ErrorCode: Integer;
  PythonInstalled: Boolean;
  Result1: Boolean;
  WebJRE: string;
begin
  PythonInstalled := RegKeyExists(HKLM, 'SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath');
  if PythonInstalled then
  begin
    MsgBox('installed', mbInformation, MB_OK);
  end
  else
  begin
    Result1 := MsgBox('This tool requires python Runtime Environment  to run.  Do you want to install it now ?', mbConfirmation, MB_YESNO) = IDYES;
    if not Result1 then
    begin    
      Result := False;
    end 
    else
    begin
      MsgBox('not installed', mbInformation, MB_OK);
      Result := True;

      ExtractTemporaryFile('python-2.7.5.amd64.msi')
      WebJRE:='"'+Expandconstant('{tmp}\python-2.7.5.amd64.msi')+'"'
      Exec('cmd.exe ','/c'+WebJRE,'', SW_HIDE,ewWaituntilterminated, Errorcode);
    end;
  end;
end;
于 2013-07-25T06:00:20.370 回答