Inno安装代码来安装python

时间:2013-07-24 14:08:35

标签: windows-installer inno-setup

我有一个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;

1 个答案:

答案 0 :(得分:3)

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;