从自定义操作脚本获取 msi 安装程序文件名 [英] Get msi installer filename from custom action script

查看:34
本文介绍了从自定义操作脚本获取 msi 安装程序文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 MSI Factory 构建了 msi 安装程序,其中包含几个自定义操作脚本(lua & vbs).其中一个脚本尝试从包中获取自定义属性,并在成功安装后将其写入文件.当使用参数请求下载时,此自定义属性通过 asp.NET 处理程序中的 MSI.ChangeMSIProperty 添加到下载的包中.问题是,该属性更改破坏了 msi 文件的签名,因此我们尝试向 msi 文件名添加一些数据.现在我需要更改那个 vbscript 来处理这个问题.但我无法获取安装程序文件名.

we have msi installer build with MSI Factory with a couple of custom action scripts (lua & vbs). one of the scripts try to get a custom property from package and write it to file after successfully installation. this custom property is added to downloaded package via MSI.ChangeMSIProperty in asp.NET handler when download was requested with parameters. problem is, that property change brokes the signature of msi file, so we try to add some data to the msi filename. now I need to change that vbscript to handle this. but I can't get the installers filename.

Dim data, tokens
Dim fso, f
Dim setupExeFilename, setupExeFilenameParts

data = Session.Property("CustomActionData")
tokens = Split(data,"|")

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.CreateTextFile(tokens(0) & "\\data.txt", True)

    if tokens(1) = "_DEFAULT_" then
        setupExeFilename = Session.Property("SETUPEXENAME")
        setupExeFilenameParts = Split(data,".")
        f.Write setupExeFilenameParts(UBound(setupExeFilenameParts) - 1)
    else
        f.Write tokens(1)
    end if

f.Close

我在某处找到了 Session.Property("SETUPEXENAME") 但对我不起作用.我在 Session、Session.Property、Session.ProductProperty、Installer 中搜索了一些属性,但还没有运气.安装程序对象在我尝试时存在,但没有属性返回我需要的内容.

I found Session.Property("SETUPEXENAME") somewhere but doesn't work for me. I search for some property in Session, Session.Property, Session.ProductProperty, Installer but no luck yet. Installer object is present as I try, but no property returns what I need.

If not Installer is nothing then
    msgbox "Installer ok"
    msgbox Installer.version
end if

是否可以获取安装程序文件名?

is it possible to get the installer filename?

推荐答案

OriginalDatabase 属性 有您要找的东西.但是,您对 CustomActionData 的引用告诉我您的自定义操作正在延迟上下文中运行.您将无权访问此属性.无论立即运行并序列化您的 CustomActionData 属性的任何自定义操作都必须获取此属性并将其放入 CustomActionData.

The OriginalDatabase property has what you are looking for. However your reference to CustomActionData tells me your custom action is running in the deferred context. You won't have access to this property. Whatever custom action that is running in immediate and serializing your CustomActionData property will have to obtain this property and put it into CustomActionData.

应该警告您,VB/JScript 自定义操作以其脆弱性而闻名.您提到了 SETUPEXENAME,所以我假设您正在使用 InstallShield,因为这是一个 InstallShield 属性.我建议改用 InstallScript、C/C++ 或 C#.如果您选择 InstallScript,我在 InstallSite.org 上有一个示例 CustomActionData 序列化/反序列化模式.如果是 C#,则它内置于 Microsoft.Deployment.WindowsInstaller 库的 Session 类中.

You should be warned that VB/JScript custom actions are famous for their fragility. You mention SETUPEXENAME so I assume you are using InstallShield as this is an InstallShield property. I'd suggest using InstallScript, C/C++ or C# instead. If you choose InstallScript, I have a sample CustomActionData serialization/deserialization pattern over on InstallSite.org. If C#, it's built into the Microsoft.Deployment.WindowsInstaller library's Session class.

这篇关于从自定义操作脚本获取 msi 安装程序文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆