WiX/SetupBuilder 在 vbscript 中获取 INSTALLDIR 的值
WiX/SetupBuilder get value of INSTALLDIR in vbscript
要创建 MSI,我使用 Gradle 插件 SetupBuilder。
安装后,我需要从安装目录执行一个二进制文件。但是我无法访问 INSTALLDIR 属性:
msi {
postinst = '''
MsgBox ("INSTALLDIR: " & Session.Property("INSTALLDIR"))
'''
}
但是:
我发现 SetupBuilder 在 .wxs 文件中创建了以下自定义操作:
<CustomAction Execute="deferred" Id="Postinst_Script0" Impersonate="no" Script="vbscript">
MsgBox ("INSTALLDIR: " & Session.Property("INSTALLDIR"))
</CustomAction>
<CustomAction Id="SetPropertiesPostinst_Script0" Property="Postinst_Script0" Value="INSTALLDIR='[INSTALLDIR]';ProductCode='[ProductCode]';INSTANCE_ID='[INSTANCE_ID]'"/>
他们被这样称呼:
<InstallExecuteSequence>
<Custom Action="Postinst_Script0" Before="InstallFinalize">NOT Installed OR REINSTALL OR UPGRADINGPRODUCTCODE</Custom>
<Custom Action="SetPropertiesPostinst_Script0" Before="Postinst_Script0"/>
</InstallExecuteSequence>
根据 CustomAction Element, the combination of Property
and Value
should result in a Custom Action Type 51 上的 WiX 文档,这正是我迷路的地方。太多的未知数无法理解,只是为了访问一个简单的 属性.
谁能帮我理解;我如何访问 属性?
您的问题可能有几种可能的答案:
你可以试试:
MsgBox ("CustomActionData: " & Session.Property("CustomActionData"))
如果这项工作你可以试试:
Dim properties
loadCustomActionData properties
MsgBox ("INSTALLDIR: " & properties("INSTALLDIR"))
' =====================
' Decode the CustomActionData
' =====================
Sub loadCustomActionData( ByRef properties )
Dim data, regexp, matches, token
data = Session.Property("CustomActionData")
Set regexp = new RegExp
regexp.Global = true
regexp.Pattern = "((.*?)='(.*?)'(;|$))"
Set properties = CreateObject( "Scripting.Dictionary" )
Set matches = regexp.Execute( data )
For Each token In matches
properties.Add token.Submatches(1), token.Submatches(2)
Next
End Sub
要创建 MSI,我使用 Gradle 插件 SetupBuilder。
安装后,我需要从安装目录执行一个二进制文件。但是我无法访问 INSTALLDIR 属性:
msi {
postinst = '''
MsgBox ("INSTALLDIR: " & Session.Property("INSTALLDIR"))
'''
}
但是:
我发现 SetupBuilder 在 .wxs 文件中创建了以下自定义操作:
<CustomAction Execute="deferred" Id="Postinst_Script0" Impersonate="no" Script="vbscript">
MsgBox ("INSTALLDIR: " & Session.Property("INSTALLDIR"))
</CustomAction>
<CustomAction Id="SetPropertiesPostinst_Script0" Property="Postinst_Script0" Value="INSTALLDIR='[INSTALLDIR]';ProductCode='[ProductCode]';INSTANCE_ID='[INSTANCE_ID]'"/>
他们被这样称呼:
<InstallExecuteSequence>
<Custom Action="Postinst_Script0" Before="InstallFinalize">NOT Installed OR REINSTALL OR UPGRADINGPRODUCTCODE</Custom>
<Custom Action="SetPropertiesPostinst_Script0" Before="Postinst_Script0"/>
</InstallExecuteSequence>
根据 CustomAction Element, the combination of Property
and Value
should result in a Custom Action Type 51 上的 WiX 文档,这正是我迷路的地方。太多的未知数无法理解,只是为了访问一个简单的 属性.
谁能帮我理解;我如何访问 属性?
您的问题可能有几种可能的答案:
你可以试试:
MsgBox ("CustomActionData: " & Session.Property("CustomActionData"))
如果这项工作你可以试试:
Dim properties
loadCustomActionData properties
MsgBox ("INSTALLDIR: " & properties("INSTALLDIR"))
' =====================
' Decode the CustomActionData
' =====================
Sub loadCustomActionData( ByRef properties )
Dim data, regexp, matches, token
data = Session.Property("CustomActionData")
Set regexp = new RegExp
regexp.Global = true
regexp.Pattern = "((.*?)='(.*?)'(;|$))"
Set properties = CreateObject( "Scripting.Dictionary" )
Set matches = regexp.Execute( data )
For Each token In matches
properties.Add token.Submatches(1), token.Submatches(2)
Next
End Sub