/build/static/layout/Breadcrumb_cap_w.png

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

0 Comments   [ + ] Show comments

Answers (6)

Posted by: t_claydon 14 years ago
Senior Yellow Belt
0
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?
Posted by: HenrikSkov 14 years ago
Yellow Belt
0
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? :)
Posted by: spartacus 14 years ago
Black Belt
0
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
Posted by: captain_planet 14 years ago
Black Belt
0
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
Yellow Belt
0
Thanks spartacus, I'm using InstallShield and will try your advice with the support file. I was not aware of the SUPPORTDIR property.

/Henrik
Posted by: anonymous_9363 14 years ago
Red Belt
0
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.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ