Skip to content

Instantly share code, notes, and snippets.

@sevaa
Created June 4, 2025 13:42
Show Gist options
  • Save sevaa/39baafbd6b88115b782b37de163c84fd to your computer and use it in GitHub Desktop.
Save sevaa/39baafbd6b88115b782b37de163c84fd to your computer and use it in GitHub Desktop.
param($Src, $Dest, $Name)
function CopyRecset($Table, $KeyField)
{
$svw = $sdb.OpenView("select * from $Table where $KeyField=?")
$svw.Execute($NameParam)
$sdr = $svw.Fetch()
$dvw = $ddb.OpenView("select * from $Table")
$dvw.Execute($null)
while($null -ne $sdr)
{
$dvw.Modify(5 <# msiViewModifyMerge #>, $sdr)
$sdr = $svw.Fetch()
}
$svw.Close()
$svw = $null
$dvw.Close()
$dvw = $null
}
$inst = New-Object -COM "WindowsInstaller.Installer"
$sdb = $inst.OpenDatabase($Src, 0)
$ddb = $inst.OpenDatabase($Dest, 2)
$NameParam = $inst.CreateRecord(1)
$NameParam.StringData(1) = $Name
CopyRecset "Dialog" "Dialog"
CopyRecset "Control" "Dialog_"
CopyRecset "ControlCondition" "Dialog_"
CopyRecset "ControlEvent" "Dialog_"
$ddb.Commit()
$ddb = $null
$sdb = $null
$inst = $null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment