从 Inno Setup 执行的 PowerShell 脚本失败 "Retrieving the COM class factory for component with CLSID {XXXX} failed - error 80040154"

PowerShell script executed from Inno Setup is failing with "Retrieving the COM class factory for component with CLSID {XXXX} failed - error 80040154"

我想使用 Inno Setup 通过 IIS 将文件夹转换为应用程序。

我发现我可以用 PowerShell 做到这一点,使用

ConvertTo-WebApplication 'IIS:\Sites\Default Web Site\MY_APP'

我已将其添加到我的 Inno Setup 脚本中:

[Run]
Filename: "powershell.exe"; \
  Parameters: "-ExecutionPolicy Bypass -Command ConvertTo-WebApplication 'IIS:\Sites\Default Web Site\MY_APP'" \
  WorkingDir: {app}; Flags: runhidden 

但是 PowerShell 失败了:

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154 Class not registered

作为 32 位应用程序中的 Inno Setup,它将默认 运行 32 位版本的 PowerShell,而后者又将使用 32 位 COM classes.

ConvertTo-WebApplication 所需的 COM class 似乎仅适用于(或已注册)64 位。

添加 Flags: 64bit 使 Inno Setup 使用 64 位版本的 PowerShell。

[Run]
Filename: "powershell.exe"; \
  Parameters: "-ExecutionPolicy Bypass -Command ConvertTo-WebApplication 'IIS:\Sites\Default Web Site\MY_APP'" \
  WorkingDir: {app}; Flags: runhidden 64bit

或使用64-bit install mode.


类似问题见