How to update a COM+ applications and create its msi file using PowerShell?

坚强是说给别人听的谎言 提交于 2021-02-10 17:55:43

问题


I have a COM+ application installed on my machine which has two components. This COM+ application was created using an SetupCom.exe file which was made using C# code some years bac. It used to install and create a COM+ msi file, but now I don't have access to that code, and I need to remove one component from this COM+ application - which is no longer in use.

So, I searched using google and I found some PowerShell scripts that remove the components from the COM+ application, but they don't create the msi file. I need this updated COM+ application msi\installer file so that I can install it on multiple machines.

Below is the Script which removes the component from COM+ application, but doesn't create an updated msi file.

$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()

$app = $appColl | where {$_.Name -eq "COMAPPNAME"}
$compColl = $appColl.GetCollection("Components", $app.Key)
$compColl.Populate()

$index = 0
foreach($component in $compColl) {

    if ($component.Name -eq "SOMECOMPONENT.NAME") {
        $compColl.Remove($index)
        $compColl.SaveChanges()
    }

    $index++
 }

回答1:


Writing the below, I remembered having written something similar before. Here it is: Would this method of installing COM+ work?


There is support in all major deployment tools (thee main bullet point links) to do COM+ deployment. WiX may provide the most flexible features for COM+ installation, but I have never used them.

COM+ deployment has always been a bit strange to deal with. Despite all my years doing deployment I have only done it a few times. And several times I have had a lot of problems with it. I even had a guy make a basic "hello world" COM+ application that I sent to a deployment vendor to illustrate how they did not do COM+ properly. No luck.

Typically I have ended up exporting a COM+ installer MSI from the Component Services (Launch suggestion: Windows Key + tap R type comexp.msc and press Enter). After setting up an application as you want it running, you right click it in the list and export an MSI file (in your case I guess it should already be set up):

This exported MSI file is not - shall we say - the greatest thing since sliced bread. If you want to modify it, it will quickly break in some fashion. There is an undocumented APL file in there with COM+ settings that I never understood how to handle on my own. Just use the MSI as it is - if you can.


Some Links: I took it a bit far with these links, just go for the bolded ones.

  • Creating Installation Packages for COM+ Applications
  • Understanding COM+ Application Installation
  • C# - Retrieve properties of a COM+ component?
  • Automating COM+ Administration
  • COM+:Library vs Server Application
  • COM+ Application installation woes
  • The COM+ Event System (loosely coupled event (LCE) system)


来源:https://stackoverflow.com/questions/51695001/how-to-update-a-com-applications-and-create-its-msi-file-using-powershell

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