CustomAction read from Binary
Is it possible for a VB Script CustomAction to load a file stored in the Binary table? I dont want to place the file beside the MSI and my CustomAction has to run during the InstallUISequence, so no files copied to disk at this point.
Can anyone paste a small code sample if this is possible?
/Henrik
Can anyone paste a small code sample if this is possible?
/Henrik
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
t_claydon
14 years ago
Posted by:
HenrikSkov
14 years ago
I have to launch a HTA from the CustomAction. If i place my HTA with my MSI file and i will launch the installation from an UNC path, the end-user will get a warning for opening the file on a network share. If my HTA is in the Binary table, it is already at a trusted location, as the user have accepted to launch the MSI from a network path once.
I hope you understand what i mean? :)
I hope you understand what i mean? :)
Posted by:
spartacus
14 years ago
Hello,
Are you using InstallShield as your packaging toolset? If so, you might consider adding your HTA file as a 'Support File' using the Support Files option in the InstallShield project.
Support Files are extracted early in the installation sequence to a temporary folder which can be referenced at any stage in the installation sequence through the SUPPORTDIR property.
So all your custom action would need to do would be to run the executable mshta.exe and supply [SUPPORTDIR]\myhtafile.hta as a command line parameter.
I don't know whether there is a WISE equivalent of the Support Files functionality, but I'm sure someone else in the forum might know (?)
Regards,
Spartacus
Are you using InstallShield as your packaging toolset? If so, you might consider adding your HTA file as a 'Support File' using the Support Files option in the InstallShield project.
Support Files are extracted early in the installation sequence to a temporary folder which can be referenced at any stage in the installation sequence through the SUPPORTDIR property.
So all your custom action would need to do would be to run the executable mshta.exe and supply [SUPPORTDIR]\myhtafile.hta as a command line parameter.
I don't know whether there is a WISE equivalent of the Support Files functionality, but I'm sure someone else in the forum might know (?)
Regards,
Spartacus
Posted by:
captain_planet
14 years ago
Hmmm.....i'm not sure Wise does have an equivalent, but here is some code that AngelD provided on another forum which extracts a file from the binary table. I've not tested it myself, but it looks like it could help you out.....obviously your CA sequencing will be important.
Function SetRegACLSupport()
Dim SetACLPath : SetACLPath = ReturnTempFile()
Call ExtractBinary("SetACL.exe", SetACLPath)
Call DeleteFile(SetACLPath)
End Function
Function ExtractBinary(BinaryName, OutputFile)
Const msiReadStreamAnsi = 2
Dim Database : Set Database = Session.Database
Dim View : Set View = Database.OpenView("SELECT * FROM Binary WHERE Name = '" & BinaryName & "'")
View.Execute
Dim Record : Set Record = View.Fetch
Dim BinaryData : BinaryData = Record.ReadStream(2, Record.DataSize(2), msiReadStreamAnsi)
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Stream : Set Stream = FSO.CreateTextFile(OutputFile, True)
Stream.Write BinaryData
Stream.Close
End Function
Function ReturnTempFile()
Const TemporaryFolder = 2
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim TempFolder : Set TempFolder = FSO.GetSpecialFolder(TemporaryFolder)
Dim Tempfile : Tempfile = FSO.GetTempName
ReturnTempFile = TempFolder.Path & "\" & Tempfile
End Function
Function DeleteFile(FilePath)
On Error Resume Next
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Call FSO.DeleteFile(FilePath, True)
End Function
Comments:
-
Interesting....I am looking to do something simular rather than a nest msi or prereq msi..
So in the example code above...what will be the CA type decimal number if I want to execute this in the scripted (not deferred or execution) sequence?
Thanks again. - tron2ole 7 years ago
Posted by:
HenrikSkov
14 years ago
Posted by:
anonymous_9363
14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.