InstallShield 2025 Basic MSI:将属性传递给PowerShell的延迟执行自定义操作?

编程语言 2026-07-10

关于InstallShield Premier 2025与 Basic MSI安装,能否提供一个可工作的示例,将类似TEST_ID的属性传递给以系统上下文以延期执行的PowerShell脚本自定义操作?

旧的Revenera指南显然是在他们改用Net.CLR来运行PowerShell之前编写的 - https://community.revenera.com/s/article/how-to-access-msi-property-with-a-deferred-custom-action

如果我按照他们的配方,使用Set Property CA类型51,Property = PowerShell动作名称Value = [TEST_ID],然后把他们的代码放到PowerShell脚本中,我在日志中就会看到错误,脚本也会退出。

param ($propertyName)
$testId = get-property -name $propertyName

日志:

MSI (s) (A8:1C) [16:40:37:530]: Executing op: CustomActionSchedule(Action=TestReg,ActionType=3073,Source=BinaryData,Target=m2,CustomActionData=554667889)
MSI (s) (A8:B8) [16:40:37:534]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSIACF3.tmp, Entrypoint: m2
...
Server with PID 11524 (0x2D04).
MSI (s) (A8:DC) [16:40:37:576]: Running as a service.
MSI (s) (A8:DC) [16:40:37:579]: Hello, I'm your 32bit Elevated Non-remapped custom action server.
InstallShield: Attempting to load through CLR 4 APIs...
InstallShield: Getting meta host...
...
InstallShield: Ignoring CustomActionData substring "554667889"
InstallShield: Deferred action requested property MsiHiddenProperties not provided by CustomActionData
InstallShield: Calling method with parameters [(System.UInt32)11, (System.String)C:\WINDOWS\SystemTemp\7561a5ce-1b05-4f79-b35e-719d7c84f388\test-4.ps1]
PowerShell wrapper: Ignoring CustomActionData substring "554667889"
PowerShell wrapper: Deferred action requested property MsiHiddenProperties not provided by CustomActionData

我已经做过网络搜索并咨询过聊天机器人,但发现有很多旧且相互矛盾的建议,涉及Set Property数据格式和PowerShell命令的不同排列组合。一个在最新InstallShield上可工作的简单示例将非常有帮助。

注意:所给出的答案仅适用于Advanced Installer,而且针对InstallShield的即时(Immediate)自定义操作,而非延期(Deferred)。延期自定义操作无法直接访问属性。

解决方案

你必须使用CustomActionData属性。请在Google上搜索“在延迟自定义操作中访问属性”的方法。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章