简体   繁体   English

Inno Setup在安装后不运行程序

[英]Inno Setup doesn't run program post install

I'm encountering a weird bug concerning Inno Setup. 我遇到一个与Inno Setup有关的怪异错误。 I have a Python program packaged with PyInstaller that detects and downloads updates to itself (which are also Inno installers). 我有一个与PyInstaller打包在一起的Python程序,该程序可以检测并下载对自身的更新(也是Inno安装程序)。

When the user runs the setup file by itself, running the program post install works. 当用户自己运行安装文件时,运行安装后的程序即可。 But, when I run the setup EXE from within the program, the whole setup still runs, but the post install doesn't work. 但是,当我从程序中运行安装程序EXE时,整个安装程序仍会运行,但是安装后无法正常工作。

I made sure that my process was completely separate and disjoint with the following code: 我确保我的过程是完全独立的,并且与以下代码脱节:

CREATE_NEW_PROCESS_GROUP = 0x00000200
DETACHED_PROCESS = 0x00000008

kwargs = {}
kwargs.update(creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
kwargs.update(close_fds=True)

p = subprocess.Popen('"' + exePath + '"', **kwargs)

What's really frustrating with this is that running this from the original Python program works! 真正令人沮丧的是,可以从原始Python程序运行此命令! It's only when it is packaged with PyInstaller that the post install doesn't work. 仅当与PyInstaller打包在一起时,安装后的功能才起作用。

I have no idea where to look to figure out this problem nor how to debug it. 我不知道在哪里可以找到解决这个问题的方法,也不知道如何调试它。 Your ideas and theories are much appreciated! 非常感谢您的想法和理论!

EDIT: 编辑:

Here is a small test program that demonstrates my problems (file called test_runner.py): 这是一个演示我的问题的小型测试程序(名为test_runner.py的文件):

import subprocess

def run_exe(exePath):
    '''
    Runs a .exe on Windows in a 100% separate environment.
    '''
    CREATE_NEW_PROCESS_GROUP = 0x00000200
    DETACHED_PROCESS = 0x00000008

    kwargs = {}
    kwargs.update(creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
    kwargs.update(close_fds=True)

    p = subprocess.Popen('"' + exePath + '"', **kwargs)

path = r'<some absolute path>\setup.exe'

run_exe(path)

I then compiled it with: 然后,我将其编译为:

pyinstaller.py test_runner.py

Figured it out. 弄清楚了。 It turns out that I had to clear the environment variables PYTHONHOME and PYTHONPATH so that the PyInstaller-packaged program can generate the correct paths for those variables (they were set by the previous PyInstaller-packaged program that spawned the setup). 事实证明,我必须清除环境变量PYTHONHOMEPYTHONPATH以便PyInstaller打包的程序可以为这些变量生成正确的路径(它们是由产生该设置的先前PyInstaller打包的程序设置的)。

I ended up making the Inno Setup run a batch file that cleared them before running the executable. 我最终使Inno Setup运行了一个批处理文件,该文件在运行可执行文件之前已将其清除。 I hope this helps someone out there. 我希望这可以帮助某个人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM