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

£可爱£侵袭症+ 提交于 2020-08-05 09:50:32

问题


I want to convert a folder to an application with IIS using Inno Setup.

I found that I can do it with PowerShell, using

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

I have added this to my Inno Setup script:

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

But PowerShell is failing with:

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


回答1:


As Inno Setup in a 32-bit application, it will by default run 32-bit version of PowerShell, which in turn will use 32-bit COM classes.

The COM class needed for ConvertTo-WebApplication seems to be available (or registered) for 64-bit only.

Add the Flags: 64bit to make Inno Setup use 64-bit version of PowerShell.

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

Or use the 64-bit install mode.


For a similar question, see A command in a .bat file is unrecognized when the .bat file is called from an Inno Setup but works fine when I run the bat file manually.



来源:https://stackoverflow.com/questions/63169767/powershell-script-executed-from-inno-setup-is-failing-with-retrieving-the-com-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!