Reputation: 932
I have an inno set up code , which installs python . It works fine and I am getting the setup.exe file with the set up file having the python in it. But when I tried installing python with that setup file , it didnt work.Is that because the setup file is looking for the python file specified in the file section, If so How can I change the code so that the python inside the setup.exe will be used .Also the setup is creating a default application every time when I install the set up.I have tried the attribute DisableDirPage=yes ,but it didnt work. Can any body suggest some solution to this.
#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;
Upvotes: 5
Views: 3418
Reputation: 10516
Made some changes to your script as Tlama said. Working fine at my side, Changed the File section entry and used Exec instead ShellExec...
replace python-2.7.5.amd64.msi to python-2.7.5.msi and replace D:\ to 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;
Upvotes: 5