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?

0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


The only way I can think of doing it is to create a ram disk, use the MSI SDK to extract the binary to the ram disk.

Why can't you use the HD?
Answered 02/25/2010 by: t_claydon
Senior Yellow Belt

Please log in to comment
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? :)
Answered 02/25/2010 by: HenrikSkov
Yellow Belt

Please log in to comment

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 (?)


Answered 02/25/2010 by: spartacus
Black Belt

Please log in to comment
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 & "'")
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
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
Answered 02/26/2010 by: captain_planet
Fourth Degree Brown Belt

  • 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.
Please log in to comment
Thanks spartacus, I'm using InstallShield and will try your advice with the support file. I was not aware of the SUPPORTDIR property.

Answered 02/26/2010 by: HenrikSkov
Yellow Belt

Please log in to comment
Why are you using an HTA? Surely the only reason to, over and above using VBS, is that you can create a UI? In which case, why not simply create a new dialog? Your package can then get the information it needs from the properties "behind" the various controls.
Answered 03/02/2010 by: VBScab
Red Belt

Please log in to comment