09-Setup-WaxAndTrace.ps1 Step 3: - Detect Mitutoyo's burn-time typo on 218-378-13 series cal discs (filenames carry a trailing space inside the probe ID component, e.g. "Linear_X_218-378-13 _100072210.txt"). Their own .NET Setup.exe calls FileSystemInfo.set_Attributes on the source path and throws System.ArgumentException because the path contains an embedded space component, crashing every cal apply on 218-378-13 bays (exit -532462766 = 0xE0434352, .NET unhandled exception). Confirmed via WER Event 1026 captured during today's WJF00159 imaging. - When the buggy filenames are detected, bypass the broken vendor Setup.exe and direct-copy data\*.* into C:\Program Files (x86)\MitutoyoApp\Formtracepak\data\, renaming each file to strip ' _' (space-underscore) -> '_'. Clear read-only attr on each landed file. Older 218-458A discs have clean filenames and still use the vendor Setup.exe path. waxtrace-manifest.json: - Drop DetectionValue=v14.15.26706 from both VC++ 2017 redist entries. Windows Update routinely bumps the VS14 runtime to 14.16+ / 14.3x+, the older Mitutoyo redist refuses to install over the newer (exit 1638 'Another version already installed') and the manifest engine marked it as failed even though the runtime was fine. Detection is now by registry-key+name presence, which any VC++ 2015-2022 redist satisfies (they are backward-compatible). startnet.cmd:prompt_waxtrace_asset: - Replace free-text input with select-waxtrace-asset.ps1 arrow-key picker driven from installers-post/waxtrace/calibrations/INDEX.csv. - Map Y: enrollment share early so the picker can read INDEX.csv. - Replace parens-in-parens block (echo of '(e.g. WJRP2335)' inside the if-paren caused 'to was unexpected at this time' parse error observed by tech mid-imaging) with goto-flow. - Fall back to free-text prompt if picker unavailable or operator presses Esc. select-waxtrace-asset.ps1: - Sort bays descending by asset tag so WJRP* lands at top of menu. - Also staged as gea-shopfloor-waxtrace/select-waxtrace-asset.ps1 so sync-waxtrace.sh ships it to installers-post/waxtrace/ on the share. sync-waxtrace.sh: - Push select-waxtrace-asset.ps1 next to INDEX.csv on the share. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
103 lines
3.5 KiB
PowerShell
103 lines
3.5 KiB
PowerShell
# select-waxtrace-asset.ps1 - Arrow-key bay picker for wax/trace imaging.
|
|
#
|
|
# Reads the calibration INDEX.csv on the PXE share to build the menu of known
|
|
# bays. Operator picks with Up/Down arrows + Enter. Always appends an
|
|
# "Other (new bay)" option at the end for bays that don't have a cal ISO yet -
|
|
# selecting it falls back to a free-text prompt.
|
|
#
|
|
# Writes the chosen asset tag to $OutFile (one line, no trailing newline).
|
|
# startnet.cmd reads that file back into the MACHINENUM batch var.
|
|
#
|
|
# Runs in WinPE PowerShell. Win10/11 WinPE ships powershell.exe with
|
|
# System.Console.ReadKey support. Tested 2026-05-18.
|
|
#
|
|
# Exit codes:
|
|
# 0 = asset tag written to $OutFile
|
|
# 1 = user cancelled (Esc) - $OutFile not written
|
|
# 2 = INDEX.csv unreadable AND no fallback entered
|
|
|
|
param(
|
|
[string]$IndexPath = 'Y:\installers-post\waxtrace\calibrations\INDEX.csv',
|
|
[Parameter(Mandatory=$true)][string]$OutFile
|
|
)
|
|
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
function Read-BayList {
|
|
param([string]$Path)
|
|
if (-not (Test-Path -LiteralPath $Path)) { return @() }
|
|
try {
|
|
return Import-Csv -LiteralPath $Path |
|
|
Select-Object -Property asset_tag, unit_serial, probe_part |
|
|
Sort-Object -Property asset_tag -Descending
|
|
} catch {
|
|
return @()
|
|
}
|
|
}
|
|
|
|
function Show-Menu {
|
|
param(
|
|
[object[]]$Items,
|
|
[int]$Selected,
|
|
[string]$Title
|
|
)
|
|
Clear-Host
|
|
Write-Host ""
|
|
Write-Host " ========================================"
|
|
Write-Host " $Title"
|
|
Write-Host " ========================================"
|
|
Write-Host ""
|
|
Write-Host " Up / Down arrows = navigate, Enter = select, Esc = cancel"
|
|
Write-Host ""
|
|
for ($i = 0; $i -lt $Items.Count; $i++) {
|
|
$item = $Items[$i]
|
|
$line = if ($item -is [string]) { $item } else { "{0,-10} serial={1,-12} probe={2}" -f $item.asset_tag, $item.unit_serial, $item.probe_part }
|
|
if ($i -eq $Selected) {
|
|
Write-Host (" > " + $line) -ForegroundColor Black -BackgroundColor White
|
|
} else {
|
|
Write-Host (" " + $line)
|
|
}
|
|
}
|
|
Write-Host ""
|
|
}
|
|
|
|
$bays = @(Read-BayList -Path $IndexPath)
|
|
$menuItems = @()
|
|
foreach ($b in $bays) { $menuItems += $b }
|
|
$menuItems += '** Other (new bay - enter asset tag manually) **'
|
|
|
|
$sel = 0
|
|
while ($true) {
|
|
Show-Menu -Items $menuItems -Selected $sel -Title "Wax/Trace Asset Tag"
|
|
$key = [System.Console]::ReadKey($true)
|
|
switch ($key.Key) {
|
|
'UpArrow' { if ($sel -gt 0) { $sel-- } }
|
|
'DownArrow' { if ($sel -lt ($menuItems.Count - 1)) { $sel++ } }
|
|
'Enter' {
|
|
if ($sel -eq ($menuItems.Count - 1)) {
|
|
# Manual entry
|
|
Write-Host ""
|
|
$manual = Read-Host " Enter asset tag (e.g. WJRP9999) or blank to abort"
|
|
if ($manual) {
|
|
$manual = $manual.Trim().ToUpper()
|
|
Set-Content -LiteralPath $OutFile -Value $manual -NoNewline -Encoding ascii
|
|
Write-Host ""
|
|
Write-Host " Saved asset tag: $manual"
|
|
Start-Sleep -Seconds 1
|
|
exit 0
|
|
} else {
|
|
exit 1
|
|
}
|
|
} else {
|
|
$pick = $bays[$sel].asset_tag
|
|
Set-Content -LiteralPath $OutFile -Value $pick -NoNewline -Encoding ascii
|
|
Write-Host ""
|
|
Write-Host " Selected: $pick"
|
|
Start-Sleep -Seconds 1
|
|
exit 0
|
|
}
|
|
}
|
|
'Escape' { exit 1 }
|
|
}
|
|
}
|