UDC: correct CLI arg signature to compact site + dash-prefixed machine#
UDC_Setup.exe and UDC.exe expect: UDC_Setup.exe WestJefferson -7605 Not the spaced-quoted positional pair we'd been passing: UDC_Setup.exe "West Jefferson" 7605 The wrong format meant UDC ignored both args, fell back to defaults (Site=Evendale, MachineNumber=blank). Combined with the kill-after-detect window, neither value got persisted to udc_settings.json regardless of whether UDC.exe was given time to write. Changes: - preinstall.json: UDC InstallArgs now "WestJefferson -9999" - 00-PreInstall-MachineApps.ps1: site override now matches/replaces the compact 'WestJefferson' token (not 'West Jefferson') and uses siteNameCompact from site-config; targetNum extraction regex updated to '-(\d+)$' for the new dash-prefix format - Update-MachineNumber.ps1: UDC.exe relaunch now passes positional compact-site + dash-prefixed number instead of -site/-machine flags Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -138,7 +138,7 @@
|
||||
"Name": "UDC",
|
||||
"Installer": "UDC_Setup.exe",
|
||||
"Type": "EXE",
|
||||
"InstallArgs": "\"West Jefferson\" 9999",
|
||||
"InstallArgs": "WestJefferson -9999",
|
||||
"KillAfterDetection": true,
|
||||
"DetectionMethod": "Registry",
|
||||
"DetectionPath": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\UDC",
|
||||
|
||||
@@ -122,18 +122,21 @@ if (-not $config.Applications) {
|
||||
Write-PreInstallLog "Staged installer dir: $installerDir"
|
||||
Write-PreInstallLog "Found $($config.Applications.Count) app entries in preinstall.json"
|
||||
|
||||
# --- Site-name override: replace "West Jefferson" in InstallArgs if site-config says otherwise ---
|
||||
# --- Site-name override: replace 'WestJefferson' (compact, no space) in
|
||||
# InstallArgs if site-config says otherwise. UDC_Setup.exe expects the
|
||||
# compact site name as positional arg 1; the spaced variant is used in
|
||||
# other places (eDNC SITESELECTED MSI property) but not here.
|
||||
$siteConfig = Get-SiteConfig
|
||||
if ($siteConfig -and $siteConfig.siteName -and $siteConfig.siteName -ne 'West Jefferson') {
|
||||
Write-PreInstallLog "Site config loaded - siteName: $($siteConfig.siteName)"
|
||||
if ($siteConfig -and $siteConfig.siteNameCompact -and $siteConfig.siteNameCompact -ne 'WestJefferson') {
|
||||
Write-PreInstallLog "Site config loaded - siteNameCompact: $($siteConfig.siteNameCompact)"
|
||||
foreach ($app in $config.Applications) {
|
||||
if ($app.InstallArgs -and $app.InstallArgs -match 'WestJefferson') {
|
||||
$app.InstallArgs = $app.InstallArgs -replace 'West Jefferson', $siteConfig.siteName
|
||||
$app.InstallArgs = $app.InstallArgs -replace 'WestJefferson', $siteConfig.siteNameCompact
|
||||
Write-PreInstallLog " Overrode site name in $($app.Name) args: $($app.InstallArgs)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-PreInstallLog "No site-config override for siteName (using defaults in preinstall.json)"
|
||||
Write-PreInstallLog "No site-config override for siteNameCompact (using defaults in preinstall.json)"
|
||||
}
|
||||
|
||||
# --- Machine-number override: replace "9999" in UDC InstallArgs if tech entered a number ---
|
||||
@@ -310,9 +313,36 @@ foreach ($app in $config.Applications) {
|
||||
Write-PreInstallLog " Detection passed at $elapsed s - killing installer to advance (KillAfterDetection)"
|
||||
try { $proc.Kill(); $proc.WaitForExit(5000) | Out-Null } catch { }
|
||||
|
||||
# UDC's installer auto-launches UDC.exe in silent mode. Kill that too
|
||||
# so it can't write the placeholder MachineNumber to udc_settings.json.
|
||||
# UDC's installer auto-launches UDC.exe silently; it's UDC.exe
|
||||
# (not UDC_Setup) that actually writes udc_settings.json from
|
||||
# the CLI args. Killing it immediately after the detection
|
||||
# marker appears loses the MachineNumber write. Wait (up to
|
||||
# 15s) for settings.json to reflect the target number, then
|
||||
# kill. Works uniformly for tech-typed numbers and the 9999
|
||||
# placeholder - whichever was passed as arg 2 is what we
|
||||
# expect to see persist.
|
||||
if ($app.Name -eq "UDC") {
|
||||
$udcJson = 'C:\ProgramData\UDC\udc_settings.json'
|
||||
$targetNum = $null
|
||||
if ($app.InstallArgs -match '-(\d+)\s*$') { $targetNum = $matches[1] }
|
||||
$waitSec = 0
|
||||
while ($waitSec -lt 15) {
|
||||
if (Test-Path $udcJson) {
|
||||
try {
|
||||
$mn = (Get-Content $udcJson -Raw -ErrorAction Stop |
|
||||
ConvertFrom-Json).GeneralSettings.MachineNumber
|
||||
if ($mn -and $mn -eq $targetNum) {
|
||||
Write-PreInstallLog " UDC persisted MachineNumber=$mn after $waitSec s"
|
||||
break
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
Start-Sleep -Seconds 1
|
||||
$waitSec++
|
||||
}
|
||||
if ($waitSec -ge 15) {
|
||||
Write-PreInstallLog " UDC did not persist MachineNumber within 15 s - killing anyway" "WARN"
|
||||
}
|
||||
Get-Process UDC -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
try { $_.Kill(); $_.WaitForExit(2000) | Out-Null } catch { }
|
||||
}
|
||||
|
||||
@@ -129,7 +129,10 @@ function Update-MachineNumber {
|
||||
# --- Relaunch UDC with new args ---
|
||||
if ((Test-Path $script:UdcExePath) -and $out.UdcUpdated) {
|
||||
try {
|
||||
Start-Process -FilePath $script:UdcExePath -ArgumentList @('-site', "`"$Site`"", '-machine', $NewNumber)
|
||||
# UDC.exe arg signature: positional compact-site (no space), then
|
||||
# dash-prefixed machine number. Example: UDC.exe WestJefferson -7605
|
||||
$siteCompact = ($Site -replace '\s+','')
|
||||
Start-Process -FilePath $script:UdcExePath -ArgumentList @($siteCompact, "-$NewNumber")
|
||||
} catch {
|
||||
$out.Errors += "UDC relaunch failed: $_"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user