Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to executing a python script with innoSetup
    primarykey
    data
    text
    <p>I try to run a python script during a setup generate by InnoSetup , but nothing works. Neither the Run section or Exec in code section Result code differ depending the way I call it.</p> <p>Of course I install Python during the setup if it's not already present. Here is the test code Inno </p> <pre><code>[Setup] AppName=PyPy_client AppVersion=0.1 DefaultDirName={pf}\DeployPyPy UninstallDisplayIcon={app}\test.py Compression = zip/1 OutputDir=deploy SetupLogging = yes UsePreviousGroup=False DisableProgramGroupPage=yes PrivilegesRequired = admin [Files] Source: "D:\Dev\deploy_python\python-3.3.2.msi"; DestDir: "{app}\deploy"; Flags: ignoreversion Source: "D:\Dev\deploy_python\test.py"; DestDir: "{app}"; Flags: ignoreversion [Run] Filename: "msiexec"; Parameters: "/i ""{app}\deploy\python-3.3.2.msi"" /qb! ALLUSER=1 ADDLOCAL=ALL"; WorkingDir: "{app}\deploy"; Flags: 32bit; Check: python_is_installed Filename: "cmd.exe"; Parameters: "/c{code:GetPythonPath}\python.exe {app}\test.py"; WorkingDir: "{app}"; Flags: waituntilterminated [Code] function python_is_installed() : Boolean; var key : string; begin //check registry key := 'software\Python\PythonCore\3.3\InstallPath' Result := not RegValueExists(HKEY_LOCAL_MACHINE,Key,''); end; function GetPythonPath(Param : String) : String; var dir, key : String; begin dir := ''; key := 'software\Python\PythonCore\3.3\InstallPath' RegQueryStringValue(HKEY_LOCAL_MACHINE,key,'',dir); Result := dir end; procedure DeinitializeSetup(); var ResultCode: integer; begin if Exec('cmd.exe', ExpandConstant('/c' +GetPythonPath('')+ '\python.exe {app}\test.py'), '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then Log(intTostr(Resultcode)); end; </code></pre> <p>I Try to use directly python.exe in Run section and in code:Exec but no way.</p> <p>And of course if I type test.py in windows command line it works , and the cmd.exe /cC:\python33\python.exe C:\app\test.py also </p> <p>Somebody already succes using python script with innosetup ? </p> <p>The purpose of this is not to distribute py file of an app but using python script during the installation process to make some stuff.</p> <p>Now I m' using CXfreeeze to make an exe of the scripts but I prefer to keep only the python script and not exe (for automatisation purpose)</p> <p>for information python test script is just :</p> <pre><code>import ctypes def msgbox(message,title): ctypes.windll.user32.MessageBoxW(0, message, title, 0) def debug() : msgbox('test','test test') debug() </code></pre> <p><strong>EDIT *</strong></p> <p>As @Tlama suggest I have tried to use the command in [Run] using OriginalUser instead of the Admin mode setted by inno (I m using the PrivilegesRequired = admin ) but it doesn't Work.</p> <p>And as I install python for all users with the command line ALLUSERS=1 existing users (or admin) can run python scripts.</p> <p>I also try to modify the WorkingDir in [Run] and in CODE:Exec but all tentatives give me the same ResultCode "2"</p> <pre><code>Filename: "cmd.exe"; Parameters: "/c{code:GetPythonPath}\python.exe {app}\test.py"; WorkingDir: "{app}"; Flags: waituntilterminated Filename: "cmd.exe"; Parameters: "/c{code:GetPythonPath}\python.exe {app}\test.py"; WorkingDir: "{code:GetPythonPath}"; Flags: waituntilterminated Filename: "python.exe"; Parameters: "{app}\test.py"; WorkingDir: "{code:GetPythonPath}"; Flags: waituntilterminated Filename: "python.exe"; Parameters: "{app}\test.py"; WorkingDir: "{app}"; Flags: waituntilterminated </code></pre> <p>in CODE : </p> <pre><code> Log('Start pypy 1'); Exec('cmd.exe', ExpandConstant('/c' +GetPythonPath('')+ '\python.exe {app}\test.py'), GetPythonPath(''), SW_SHOW, ewWaitUntilTerminated, ResultCode); Log(intToStr(Resultcode)); Log('Start pypy 2'); Exec(GetPythonPath('')+ '\python.exe', ExpandConstant('{app}\test.py'), GetPythonPath(''), SW_SHOW, ewWaitUntilTerminated, ResultCode); Log(intToStr(Resultcode)); Log('Start pypy 3'); Exec('cmd.exe', ExpandConstant('/c' +GetPythonPath('')+ '\python.exe {app}\test.py'),ExpandConstant('{app}'), SW_SHOW, ewWaitUntilTerminated, ResultCode); Log(intToStr(Resultcode)); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload