Skip to content

Instantly share code, notes, and snippets.

@Shenderchuk
Created December 13, 2016 15:28
Show Gist options
  • Select an option

  • Save Shenderchuk/4b98a42b81721c79509e5ba98f6dd39c to your computer and use it in GitHub Desktop.

Select an option

Save Shenderchuk/4b98a42b81721c79509e5ba98f6dd39c to your computer and use it in GitHub Desktop.
#Copy dll from WiX binary files (version 3.10.3)
# Add Required Type Libraries
Add-Type -Path "C:\Temp\Microsoft.Deployment.WindowsInstaller.dll"
# Open an MSI Database
$oDatabase = New-Object Microsoft.Deployment.WindowsInstaller.Database("C:\Temp\Bliss_LP_net.msi", [Microsoft.Deployment.WindowsInstaller.DatabaseOpenMode]::Direct);
#Create a Select Query against an individual property
$sSQLQuery = "SELECT * FROM Property WHERE Property= 'ProductCode'"
#Create and Execute a View object
[Microsoft.Deployment.WindowsInstaller.View]$oView = $oDatabase.OpenView($sSQLQuery)
$oView.Execute()
#Fetch the Result
$oRecord = $oView.Fetch()
$sProductCode = $oRecord.GetString(2)
#Display Retrieved Field
"ProductCode = $($sProductCode)"
#Generate new random guid
$newProductCode = "{$((New-Guid).guid)}"
"newProductCode = $($newProductCode)"
$oRecord.SetString("Value",$newProductCode)
$oView.Modify([Microsoft.Deployment.WindowsInstaller.ViewModifyMode]::Update,$oRecord)
#Close the Database
$oView.Close();
$oDatabase.Dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment