cx_Freeze msi安装后

时间:2018-11-12 13:48:30

标签: windows-installer cx-freeze

我有一个要包装在MSI中的软件包,该软件包需要在安装后使用命令行参数注册DLL。使用cx_Freeze,我可以添加一个自定义操作并将其添加到要在安装过程中运行的执行序列中,但是无论我将其放置在序列中的什么位置,除非我在运行安装程序之前将文件复制到目标安装目录中,否则该命令都会失败。 / p>

我的设置文件是:

#!python3

import os, sys, shutil, platform
from cx_Freeze import setup

command_line = 'regsvr32.exe /s /i:"stuff_here" MyDLL.dll'

files = ['MyDLL.dll']

if platform.architecture()[0] == '32bit':
    builddir = 'build/bdist.win32/msi'
else:
    builddir = 'build/bdist.win-amd64/msi'

os.makedirs(builddir, exist_ok=True)

for file in files:
    shutil.copyfile(file, os.path.join(builddir, file))

if 'bdist_msi' in sys.argv:
    sys.argv += ['--initial-target-dir', '[ProgramFilesFolder]DLL_Thing']

custom_action_table = []
if command_line != '':
    custom_action_table.append(
        # action to take to register DLL
        (
            'RegisterDLLs',                 # action key name
            34,                             # type (EXE file having a path referencing a directory.)
            'TARGETDIR',                    # 
            command_line,                   # command line
        ),
    )

install_execute_sequence_table = []
if command_line != '':
    install_execute_sequence_table.append(
        # call regsvr after rest of product finishes installing.
    (
            'RegisterDLLs', # action key name
            None,           # condition
            6501,           # sequence
        ),
    )

# Change some default MSI options and specify the use of the above defined tables
bdist_msi_options = {
    'data': {
        'CustomAction': custom_action_table,
        'InstallExecuteSequence': install_execute_sequence_table
    },
}

setup(  name = 'DLL Thing',
        version = '1.0.0',
        description = 'DLL Thing',
        options = {'build_exe': {'include_files': files}, 'bdist_msi': bdist_msi_options,},
    )

通读我的installsequeuence表:

LaunchConditions        100
FindRelatedProducts     200
AppSearch       400
A_SET_TARGET_DIR    TARGETDIR=""    401
CCPSearch   NOT Installed   500
RMCCPSearch NOT Installed   600
ValidateProductID       700
CostInitialize      800
FileCost        900
IsolateComponents       950
CostFinalize        1000
SetODBCFolders      1100
MigrateFeatureStates        1200
InstallValidate     1400
RemoveExistingProducts      1450
InstallInitialize       1500
AllocateRegistrySpace   NOT Installed   1550
ProcessComponents       1600
UnpublishComponents     1700
MsiUnpublishAssemblies      1750
UnpublishFeatures       1800
StopServices    VersionNT   1900
DeleteServices  VersionNT   2000
UnregisterComPlus       2100
SelfUnregModules        2200
UnregisterTypeLibraries     2300
RemoveODBC      2400
UnregisterFonts     2500
RemoveRegistryValues        2600
UnregisterClassInfo     2700
UnregisterExtensionInfo     2800
UnregisterProgIdInfo        2900
UnregisterMIMEInfo      3000
RemoveIniValues     3100
RemoveShortcuts     3200
RemoveEnvironmentStrings        3300
RemoveDuplicateFiles        3400
RemoveFiles     3500
RemoveFolders       3600
CreateFolders       3700
MoveFiles       3800
InstallFiles        4000
PatchFiles      4090
DuplicateFiles      4210
BindImage       4300
CreateShortcuts     4500
RegisterClassInfo       4600
RegisterExtensionInfo       4700
RegisterProgIdInfo      4800
RegisterMIMEInfo        4900
WriteRegistryValues     5000
WriteIniValues      5100
WriteEnvironmentStrings     5200
RegisterFonts       5300
InstallODBC     5400
RegisterTypeLibraries       5500
SelfRegModules      5600
RegisterComPlus     5700
InstallServices VersionNT   5800
StartServices   VersionNT   5900
RegisterUser        6000
RegisterProduct     6100
PublishComponents       6200
MsiPublishAssemblies        6250
PublishFeatures     6300
PublishProduct      6400
RegisterDLLs        6501
InstallFinalize     6600

文件应按顺序4000安装,但在6501尝试注册DLL时,文件尚未出现在磁盘上(使用sysinternals procmon,我可以看到引发的错误是由于找不到文件)

如果我尝试在完成阶段(6601)之后运行,则安装程序已放弃管理员特权,并且无​​法注册dll。

我如何达到我想要的结果?

0 个答案:

没有答案