InnoSetupによって生成されるセットアップ中にPythonスクリプトを実行しようとしましたが、何も動作しません。 [実行]セクションまたは[コードで実行]セクションの結果コードは、呼び出す方法によって異なります。innoSetupでpythonスクリプトを実行する方法
もちろん、セットアップ中にPythonがまだインストールされていない場合はインストールします。 Execのが、決して:ここに は、私が直接ファイル名を指定して実行]セクションで、コードでpython.exe使用してみてくださいテストコードイノ
[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;
です。
そして、私は、Windowsのコマンドラインでtest.py入力すると、もちろん、それが動作し、cmd.exeの/cC:\python33\python.exe C:\アプリケーションの\ test.pyも
誰かがすでに大成功innosetupでpythonスクリプトを使用して?
この目的は、アプリケーションのpyファイルを配布するのではなく、インストールプロセス中にpythonスクリプトを使用していくつかのものを作ることです。
今私は、スクリプトのexeファイルを作るためにCXfreeezeを使用して「Mが、私は(automatisationの目的のために)exeファイルのみPythonスクリプトを維持していないことを好む
情報Pythonのテストスクリプトのためだけである:
import ctypes
def msgbox(message,title):
ctypes.windll.user32.MessageBoxW(0, message, title, 0)
def debug() :
msgbox('test','test test')
debug()
@Tlamaとして
EDIT *
私が代わりにINNOによってsetted管理者モードのOriginalUserを使用して、[ファイル名を指定して実行]でコマンドを使用しようとしました示唆(私はPrivilegesRequired =管理者を使用してM)それ動作しません。
コマンドラインですべてのユーザー用にPythonをインストールすると、既存のユーザー(または管理者)ALLUSERS = 1はPythonスクリプトを実行できます。 Execのが、すべてのtentativesは私に同じResultCodeのCODEで "2"
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でWORKINGDIRを変更しようと
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));
はい私も試してみてください: "python.exe" "C:\ pyhton33 \ pyhton.exe test.py" thスクリプトだけ(pythonと.pyはpython.exeにリンクしています) "test.py"何も働かない。 – user2819873
ご協力ありがとうございます!私は元のユーザーを使用してみて、それも効果がありません。私は言及しませんでしたが、私はいくつかの作業ディレクトリ(pyhton 1、app one ..)を試してみました。私はそれがpythonに関連していると思うが、これは本当に奇妙である – user2819873
ありがとう、私は何年もInnoを使用していますが、今回は本当に立ち往生しています。 – user2819873