@@ -567,13 +567,13 @@ function New-WAUTransformFile {
567567 } else {
568568 " " # Empty string
569569 }
570-
570+
571571 $properties [' MODSPATH' ] = if (! [string ]::IsNullOrWhiteSpace($controls.ModsPathTextBox.Text )) {
572572 $controls.ModsPathTextBox.Text
573573 } else {
574574 " " # Empty string
575575 }
576-
576+
577577 $properties [' AZUREBLOBSASURL' ] = if (! [string ]::IsNullOrWhiteSpace($controls.AzureBlobSASURLTextBox.Text )) {
578578 $controls.AzureBlobSASURLTextBox.Text
579579 } else {
@@ -611,26 +611,32 @@ function New-WAUTransformFile {
611611 foreach ($propName in $properties.Keys ) {
612612 $propValue = $properties [$propName ]
613613
614+ # Ensure empty strings are handled properly for MSI
615+ if ([string ]::IsNullOrEmpty($propValue )) {
616+ $propValue = " "
617+ }
618+
614619 try {
615- # Try to update existing property first
616- $updateView = $modifiedDb.GetType ().InvokeMember(" OpenView" , " InvokeMethod" , $null , $modifiedDb , " UPDATE Property SET Value = '$propValue ' WHERE Property = '$propName '" )
617- $updateView.GetType ().InvokeMember(" Execute" , " InvokeMethod" , $null , $updateView , $null )
618- $updateView.GetType ().InvokeMember(" Close" , " InvokeMethod" , $null , $updateView , $null )
619- [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($updateView ) | Out-Null
620-
621- # If UPDATE didn't work, try INSERT
620+ # Try INSERT first, then UPDATE if it fails
622621 $insertView = $modifiedDb.GetType ().InvokeMember(" OpenView" , " InvokeMethod" , $null , $modifiedDb , " INSERT INTO Property (Property, Value) VALUES ('$propName ', '$propValue ')" )
623622 try {
624623 $insertView.GetType ().InvokeMember(" Execute" , " InvokeMethod" , $null , $insertView , $null )
625624 }
626625 catch {
627- # Property already exists or other issue, continue
626+ # Property might already exist, try UPDATE instead
627+ $insertView.GetType ().InvokeMember(" Close" , " InvokeMethod" , $null , $insertView , $null )
628+ [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($insertView ) | Out-Null
629+
630+ $updateView = $modifiedDb.GetType ().InvokeMember(" OpenView" , " InvokeMethod" , $null , $modifiedDb , " UPDATE Property SET Value = '$propValue ' WHERE Property = '$propName '" )
631+ $updateView.GetType ().InvokeMember(" Execute" , " InvokeMethod" , $null , $updateView , $null )
632+ $updateView.GetType ().InvokeMember(" Close" , " InvokeMethod" , $null , $updateView , $null )
633+ [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($updateView ) | Out-Null
634+ continue
628635 }
629636 $insertView.GetType ().InvokeMember(" Close" , " InvokeMethod" , $null , $insertView , $null )
630637 [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($insertView ) | Out-Null
631638 }
632639 catch {
633- # Continue even if property update fails
634640 Write-Warning " Failed to set property $propName = $propValue "
635641 }
636642 }
@@ -647,8 +653,25 @@ function New-WAUTransformFile {
647653 # Copy GUID to clipboard
648654 Set-Clipboard - Value $guid
649655
650- # Create summary of properties set (exclude empty values from display)
651- $propertiesSummary = ($properties.GetEnumerator () | Where-Object { $_.Value -ne " " } | ForEach-Object { " $ ( $_.Key ) =$ ( $_.Value ) " }) -join " `n "
656+ # Sort properties for display according to the form order
657+ $propertyOrder = @ (
658+ ' UPDATESINTERVAL' , ' NOTIFICATIONLEVEL' , ' UPDATESATTIME' , ' UPDATESTIMEDELAY' ,
659+ ' LISTPATH' , ' MODSPATH' , ' AZUREBLOBSASURL' ,
660+ ' DISABLEAUTOUPDATE' , ' UPDATEPRERELEASE' , ' DONOTRUNONMETERED' ,
661+ ' STARTMENUSHORTCUT' , ' DESKTOPSHORTCUT' , ' APPINSTALLERSHORTCUT' ,
662+ ' UPDATESATLOGON' , ' USERCONTEXT' , ' BYPASSLISTFORUSERS' , ' USEWHITELIST' ,
663+ ' MAXLOGFILES' , ' MAXLOGSIZE' , ' REBOOT'
664+ )
665+ # Create summary of properties set (in form order, show ALL values including empty ones)
666+ $propertiesSummary = ($propertyOrder | ForEach-Object {
667+ if ($properties.ContainsKey ($_ )) {
668+ if ($properties [$_ ] -eq " " ) {
669+ " $_ =(empty)"
670+ } else {
671+ " $_ =$ ( $properties [$_ ]) "
672+ }
673+ }
674+ }) -join " `n "
652675
653676 # Create a .cmd file with the same name as the .mst but with 'Install' appended
654677 $cmdFileName = [System.IO.Path ]::GetFileNameWithoutExtension($transformName ) + " -Install.cmd"
0 commit comments