WiX Custom Action - MSI copy itself

我与影子孤独终老i 提交于 2019-12-11 10:01:44

问题


Can someone help me to build a custom action in MSI which will copy itself after successful installation to some X location. I have already seen it can be done using .exe but I want to do it only with CA.DLL (C#) as this exe will be an overhead.


回答1:


Here's an example VB script that will find an installed product by name and copy the cached copy of the MSI. This will work on Windows 7 and later, as the full MSI is cached and any embedded cab files remain in the MSI. You just get the MSI without the payload on older systems.

Dim installer, products, product, productCode
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")

For Each productCode In installer.Products
  If InStr(1, LCase(installer.ProductInfo(productCode, "ProductName")), LCase("My Product Name")) Then Exit For
Next

If IsEmpty(productCode) Then Wscript.Quit 2

Set products = installer.ProductsEx(productCode, "", 7)
filesys.copyFile products(0).InstallProperty("LocalPackage"), "c:\path\to\newcopy.msi"


来源:https://stackoverflow.com/questions/11470760/wix-custom-action-msi-copy-itself

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