[wix-users] How to include a file as a binary and use it in a WixCA command line

sampat magi ssmcs060 at gmail.com
Fri May 6 02:03:24 PDT 2016


from wix users archives :
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Extract-Binary-file-from-MSI-to-Temp-folder-using-C-td7588682.html


Function ExtractBinary(BinaryName, OutputFile)
Const msiReadStreamAnsi = 2
Dim oDatabase
Set oDatabase = Session.Database
Dim View
Set View = oDatabase.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
Set FSO = Nothing
End Function



this is vbs function, u may want to create equivalent C# DTF CA., which u
call as fake CA


Sampat

On Fri, May 6, 2016 at 11:48 AM, Gary M <garym at oedata.com> wrote:

> Hi Sampat,
>
> Thank you for the reply and recommendations.  I think I figured out a
> workaround, but haven't had time to code it and test it. I still need to
> figure out what the installer is doing with temp files and temp file
> addressing within  the execution environment. The plan is to create a
>  "fake" custom action referencing the binary, forcing the file into the
> msi. When the msi executes, it will place the binary in the temp dir. which
> I should have access to and should be in the local context.. eg. Value="
> .\scriptName"
>
> I'd be further along, however I had 7 windows services hanging on startup
> and it took me a while to track down the issue. On windows 2008R2 if a
> service is not part of a group, the service "requires" the BasePriority
> value set in the registry. The MSI motor does not support that value, and
> as a result the services executed at the lowest possible priority ie hangs.
> A quick fix is to add the value using  <RegistryKey> writing into
> HKLM\SYSTEM\CurrentControlSet\services\$(var.ServiceName)"  and
> <RegistryValue
> Type="integer" Name="BasePriority" Value="32" KeyPath="yes"/>  The smarter
> and easier approach is to assign the service to the group, but that changes
> current operation and will need to wait for the next version to pass a
> regression cycle.
>
>
>
>
> On Thu, May 5, 2016 at 12:26 PM, sampat magi <ssmcs060 at gmail.com> wrote:
>
> > To add up to the Edwin's second point,
> >
> > If you write managed (C# DTF) CA then no need to do extra work.
> >
> > Once you create the DTF project, you can add the script item to the
> project
> > itself as an item. So that, during the execution context of the DLL CA
> file
> > will automatically get extracted to the random folder in user %temp%
> folder
> > and u can consume it inside the CA.
> >
> > I think, i have one vbs code to just extract the binary files to temp
> > location (This is similar to InstallShield's SUPPORTDIR concept).
> >
> > Sampat
> >
> > On Thu, May 5, 2016 at 11:36 PM, Edwin Castro <egcastr at gmail.com> wrote:
> >
> > > Hi Gary,
> > >
> > > Unfortunately, the Windows Installer doesn't support a way to
> > > temporarily extract a binary from the Binary table. The WiX toolset
> > > does not yet provide a mechanism to do this either although it is
> > > often requested. My guess is that there's a management element here
> > > that is difficult to schedule properly. Since the extraction should be
> > > temporary, then the file should be cleaned up toward the end of the
> > > installation.
> > >
> > > Basically, you have two options:
> > >
> > > 1. Install the binary and use it on a custom action command line
> > > (which I understand you do not want to do)
> > > 2. Write your own binary custom action (native or managed) to extract
> > > the temporary file out of the Binary table, write the file to disk,
> > > use it as part of your command line, and finally delete the temporary
> > > file.
> > >
> > > In the first case you avoid explicit clean up because the file is
> > > installed and will be uninstalled when the product is uninstalled.
> > >
> > > The second option is more work.
> > >
> > > --
> > >
> > > On Tue, May 3, 2016 at 2:07 PM, Gary M <garym at oedata.com> wrote:
> > > > Thanks for the reply Walter
> > > >
> > > > The WixCA uses a different construct. The command line is formed in a
> > > > unique customaction. The executing customaction uses the Property
> > > attribute
> > > >  to link the command line to to the WixCA dll.  I would need a
> > reference
> > > to
> > > > accessible to replace string: [INSTALLER_SCRIPTS_DIR]install-smtp.ps1
> > > >
> > > >
> > > >     <CustomAction Id="installSMTPCmdLine"
> > > >                   Property="installSMTPExec"
> > > >
> > > >
> > >
> >
> Value=""C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe"
> > > > -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile
> -InputFormat
> > > > None -File [INSTALLER_SCRIPTS_DIR]install-smtp.ps1"
> > > >                   Execute="immediate" />
> > > >
> > > >     <CustomAction Id="installSMTPExec"
> > > >                   BinaryKey="WixCA"
> > > >                   DllEntry="CAQuietExec64"
> > > >                   Execute="deferred"
> > > >                   Return="check"
> > > >                   Impersonate="no" />
> > > >
> > > >
> > > >
> > > > On Tue, May 3, 2016 at 10:51 AM, Walter Dexter <wfdexter at gmail.com>
> > > wrote:
> > > >
> > > >> Try this. I think it's right.
> > > >>
> > > >> <Binary Id="CreateHostsEXE"
> > > >> SourceFile="../../scripts/generateHostsFile.exe" />
> > > >> <CustomAction Id="OurAction"
> > > >>               FileKey="CreateHostsEXE"
> > > >>               ExeCommand="our command line args"
> > > >>               Execute="deferred"
> > > >>               Return="check" />
> > > >>
> > > >>
> > > >> On Tue, May 3, 2016 at 6:09 AM, Gary M <garym at oedata.com> wrote:
> > > >>
> > > >> > Hi,
> > > >> >
> > > >> > I have a few script files used with WixCA  command line. I would
> > like
> > > to
> > > >> > access the file without having them installed. I'm looking to
> define
> > > the
> > > >> > scripts treated as  <binary>,  but don't know how to address them
> ie
> > > push
> > > >> > them into a command line.
> > > >> >
> > > >> > Help is appreciated
> > > >> >
> > > >> >
> ____________________________________________________________________
> > > >> > WiX Toolset Users Mailing List provided by FireGiant
> > > >> > http://www.firegiant.com/
> > > >> >
> > > >>
> > > >> ____________________________________________________________________
> > > >> WiX Toolset Users Mailing List provided by FireGiant
> > > >> http://www.firegiant.com/
> > > >>
> > > >
> > > > ____________________________________________________________________
> > > > WiX Toolset Users Mailing List provided by FireGiant
> > > http://www.firegiant.com/
> > >
> > > ____________________________________________________________________
> > > WiX Toolset Users Mailing List provided by FireGiant
> > > http://www.firegiant.com/
> > >
> >
> > ____________________________________________________________________
> > WiX Toolset Users Mailing List provided by FireGiant
> > http://www.firegiant.com/
> >
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>


More information about the wix-users mailing list