For anyone who may be interested, using the DTF module with Powershell
(external to an MSI) requires code in the following format:

##### PowerShell -----
# Add Required Type Libraries 
Add-Type -Path "C:\Program Files (x86)\WiX Toolset
v4.0\bin\WixToolset.Dtf.WindowsInstaller.dll"; 

# Open an MSI Database 
$oDatabase = New-Object
WixToolset.Dtf.WindowsInstaller.Database("C:\Temp\Installer.msi",
[WixToolset.Dtf.WindowsInstaller.DatabaseOpenMode]::Direct); 

[string]$String = "INSERT INTO Property (Property,Value) VALUES
('aaaaa','bbbbb')"

$oDatabase.Execute($String);
$oDatabase.Close()

---------------------

POINTS TO NOTE

*  DatabaseOpenMode must be DIRECT.  TRANSACT with database commit will not
write the new entries to the database.

* Using the SQL "INSERT INTO" string with a database execute method works. 
creating a View object with the same syntax and executing the View does not
(although there are no errors).  

Passing and object containing field values also works as long as it is
passed to $oDatabase.Execute.  An example of that syntax is:

##### PowerShell -----
# Add Required Type Libraries 
Add-Type -Path "C:\Program Files (x86)\WiX Toolset
v4.0\bin\WixToolset.Dtf.WindowsInstaller.dll"; 

# Open an MSI Database 
$oDatabase = New-Object
WixToolset.Dtf.WindowsInstaller.Database("C:\Temp\Installer.msi",
[WixToolset.Dtf.WindowsInstaller.DatabaseOpenMode]::Direct); 

[string]$String = "INSERT INTO Property (Property,Value) VALUES (?,?)"

#Create a Record Object for the Property Table
# This requires metadata from the desired (Database) table.
[Microsoft.Deployment.WindowsInstaller.TableInfo]$targettable =
$oDatabase.Tables['Property']; 

$oRecord = New-Object
WixToolset.Dtf.WindowsInstaller.Record($targettable.columns.Count);
$oRecord.FormatString = $targettable.Columns.FormatString;
$oRecord.SetString(1,'aaa');
$oRecord.SetString(2,'bbbb');

$oDatabase.Execute($String, $oRecord);
$oDatabase.Close()
----------------------------------




--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/INSERT-INTO-an-offline-MSI-with-DTF-tp7599665p7599714.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to