Wax/Trace (gea-shopfloor-waxtrace): - captured/ holds master FormTracePak v6.0 state (Program Files reg dump gzipped, ARP entries) taken from a win11 VM where the CD-ROM-bound VB6 wrapper was driven to completion. xcopy + reg-import replays the install on real bays without running the wrapper itself. - 09-Setup-WaxAndTrace.ps1 rewrites the stub: installs prereqs via manifest (VC++ 2008/2017 x86+x64, Sentinel HASP), expands the captured zips into C:\Program Files (x86)\MitutoyoApp + C:\MitutoyoApp, imports the reg hive, then mounts the bay's per-machine cal ISO (matched by asset tag in machine-number.txt) and runs its Setup.exe. - waxtrace-manifest.json lists the 5 prereqs with InstallShield-style silent flags verified on the win11 VM. - sync-waxtrace.sh ships captured-binary/ + prereqs + cal ISOs from /home/camp/pxe-images/iso/mitutoyo-cal/ to /srv/samba/enrollment/installers-post/waxtrace/ on the PXE box. - select-waxtrace-asset.ps1 arrow-key bay picker for WinPE (parses INDEX.csv from the cal share, offers "Other (new bay)" fallback). - startnet.cmd: prompt_waxtrace_asset prompt, skip_waxtrace_stage xcopy block (mirrors :skip_cmm_stage), machine-number.txt write covers bay asset tag (WJRP*). Keyence (gea-shopfloor-keyence) - now multi-model: - vr3000/manifest.json + vr5000/manifest.json + vr6000/manifest.json (current single-model VR-6000 moved into vr6000/ subdir). Each ships the model's MSI silent-install + DetectionPath via ProductCode. Big payloads (Data1.cab, Data11.cab) gitignored, staged via sync-keyence.sh from /home/camp/pxe-images/iso/keyence/. - 09-Setup-Keyence.ps1 dispatches by C:\Enrollment\keyence-model.txt (written by startnet.cmd in :keyence_submenu) and points InstallerRoot at C:\KeyenceInstall\<model>. DXSETUP probe widened to all three Program Files paths (VR-3000 G2, VR-5000, VR-6000). - startnet.cmd: :keyence_submenu picks vr3000/vr5000/vr6000, :skip_keyence_stage xcopy block selectively stages chosen model bundle, pc-subtype.txt also written = drops directly into existing GE-Enforce PCSubType wiring (looks for gea-shopfloor-keyence-<model>\manifest.json on the tsgwp00525 share for ongoing enforcement, no dispatcher change needed). - sync-keyence.sh mirrors sync-waxtrace.sh pattern. Verified silent MSI install for VR-3000 G2 v2.5.0 and VR-5000 v3.3.1 on the win11 VM 2026-05-18 with /qn /norestart ALLUSERS=1 REBOOT=ReallySuppress TRANSFORMS=1033.mst. boot.wim on 172.16.9.1 wimupdate'd with the new startnet.cmd. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
218 lines
10 KiB
PowerShell
218 lines
10 KiB
PowerShell
# 09-Setup-WaxAndTrace.ps1 - Wax and Trace pc-type setup (Mitutoyo FormTracePak v6.0)
|
|
#
|
|
# Imaging-time install. Mitutoyo's CD-ROM-bound VB6 wrapper (Setup.exe +
|
|
# appSetup.exe) is unreliable on Win11 and requires interactive clicks
|
|
# through model + cal + HASP dialogs. We bypass it entirely: prereqs install
|
|
# via manifest, FormTracePak itself is xcopy + reg-import from a master capture.
|
|
#
|
|
# Master capture was taken 2026-05-18 on a Win11 VM with both CV-3000/4000
|
|
# series + SV-C3000/4000 series installed via Mount-DiskImage approach (see
|
|
# project-waxtrace-image.md). Covers all WJ wax/trace bays since both series
|
|
# end up sharing the same Program Files dir + reg.
|
|
#
|
|
# Layout at C:\WaxTrace-Install\ (xcopied by startnet.cmd):
|
|
# waxtrace-manifest.json
|
|
# 09-Setup-WaxAndTrace.ps1 (this file)
|
|
# prereqs\vcredist_x86.exe (VC++ 2008 x86)
|
|
# prereqs\vcredist_x64.exe (VC++ 2008 x64)
|
|
# prereqs\vc_redist.x86.exe (VC++ 2017 x86)
|
|
# prereqs\vc_redist.x64.exe (VC++ 2017 x64)
|
|
# prereqs\HASPUserSetup.exe (Sentinel Runtime / HASP dongle driver)
|
|
# captured\pf-x86-MitutoyoApp.zip (~108 MB compressed -> 675 MB)
|
|
# captured\c-MitutoyoApp.zip (data dir skeleton, mostly empty)
|
|
# captured\reg\hklm-wow-mitutoyo.reg.gz (gzipped, ~218 KB -> 5.4 MB)
|
|
# captured\arp-entries.json (informational - what to expect)
|
|
# calibrations\CAL-WJRP<asset>_serial-<sn>_probe-<probe>.iso (per-machine)
|
|
#
|
|
# Per-machine calibration is applied separately (mount cal ISO + run its
|
|
# Setup.exe), keyed by C:\Enrollment\machine-number.txt.
|
|
#
|
|
# Log: C:\Logs\WaxTrace\09-Setup-WaxAndTrace.log
|
|
# C:\Logs\WaxTrace\install.log (written by Install-FromManifest)
|
|
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
# Mirror the CMM pattern (09-Setup-CMM.ps1): the script itself lives in the
|
|
# shopfloor-setup tree (xcopied during WinPE), but the bulky bootstrap bundle
|
|
# (prereqs + captured master + cal ISOs) lives at C:\WaxTrace-Install\, put
|
|
# there by startnet.cmd from Y:\installers-post\waxtrace\ at imaging time.
|
|
$stagingRoot = 'C:\WaxTrace-Install'
|
|
$manifestPath = Join-Path $stagingRoot 'waxtrace-manifest.json'
|
|
$libSource = Join-Path $PSScriptRoot '..\common\lib\Install-FromManifest.ps1'
|
|
|
|
$logDir = 'C:\Logs\WaxTrace'
|
|
$installLog = Join-Path $logDir 'install.log'
|
|
$transcriptLog = Join-Path $logDir '09-Setup-WaxAndTrace.log'
|
|
|
|
if (-not (Test-Path $logDir)) {
|
|
New-Item -Path $logDir -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
try { Start-Transcript -Path $transcriptLog -Append -Force | Out-Null } catch {}
|
|
|
|
function Write-WTLog {
|
|
param([string]$Message, [string]$Level = 'INFO')
|
|
$stamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
Write-Host "[$stamp] [$Level] $Message"
|
|
}
|
|
|
|
Write-WTLog "================================================================"
|
|
Write-WTLog "=== WaxTrace Setup (imaging-time) session start (PID $PID) ==="
|
|
Write-WTLog "Running as: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
|
|
Write-WTLog "Script root: $PSScriptRoot"
|
|
Write-WTLog "================================================================"
|
|
|
|
# Status push - best-effort.
|
|
$pxeStatusLib = Join-Path $PSScriptRoot '..\Shopfloor\lib\Send-PxeStatus.ps1'
|
|
if (Test-Path $pxeStatusLib) {
|
|
try { . $pxeStatusLib; Send-PxeStatus -Stage '09-Setup-WaxAndTrace: starting' -StageIndex 3 -StageTotal 8 } catch { }
|
|
}
|
|
|
|
foreach ($file in @('pc-type.txt','machine-number.txt')) {
|
|
$path = "C:\Enrollment\$file"
|
|
if (Test-Path -LiteralPath $path) {
|
|
$content = (Get-Content -LiteralPath $path -First 1 -ErrorAction SilentlyContinue).Trim()
|
|
Write-WTLog " $file = $content"
|
|
} else {
|
|
Write-WTLog " $file = (not present)"
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 1: Prereqs via manifest (VC++ 2008 + 2017, HASP/Sentinel)
|
|
# ============================================================================
|
|
if (-not (Test-Path $manifestPath)) {
|
|
Write-WTLog "waxtrace-manifest.json not found at $manifestPath" 'ERROR'
|
|
} elseif (-not (Test-Path $libSource)) {
|
|
Write-WTLog "Install-FromManifest.ps1 not found at $libSource" 'ERROR'
|
|
} else {
|
|
Write-WTLog "Running Install-FromManifest (InstallerRoot=$PSScriptRoot)"
|
|
& $libSource -ManifestPath $manifestPath -InstallerRoot $stagingRoot -LogFile $installLog
|
|
$rc = $LASTEXITCODE
|
|
Write-WTLog "Install-FromManifest returned $rc"
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 2: Replay FormTracePak install from master capture
|
|
# ============================================================================
|
|
# Detection: skip if Formtracepak already present (re-run safe).
|
|
$ftpakExe = 'C:\Program Files (x86)\MitutoyoApp\Formtracepak\Formtracepak.exe'
|
|
if (Test-Path -LiteralPath $ftpakExe) {
|
|
Write-WTLog "Formtracepak.exe already present - skipping replay"
|
|
} else {
|
|
$pfZip = Join-Path $stagingRoot 'captured\pf-x86-MitutoyoApp.zip'
|
|
$maZip = Join-Path $stagingRoot 'captured\c-MitutoyoApp.zip'
|
|
$regGz = Join-Path $stagingRoot 'captured\reg\hklm-wow-mitutoyo.reg.gz'
|
|
|
|
if (-not (Test-Path $pfZip)) {
|
|
Write-WTLog "Master capture pf-x86-MitutoyoApp.zip not found at $pfZip" 'ERROR'
|
|
} else {
|
|
$pfDest = 'C:\Program Files (x86)\MitutoyoApp'
|
|
Write-WTLog "Extracting $pfZip -> $pfDest"
|
|
try {
|
|
if (-not (Test-Path $pfDest)) { New-Item -Path $pfDest -ItemType Directory -Force | Out-Null }
|
|
Expand-Archive -Path $pfZip -DestinationPath $pfDest -Force
|
|
$count = (Get-ChildItem $pfDest -Recurse -File -ErrorAction SilentlyContinue).Count
|
|
Write-WTLog " extracted $count files"
|
|
} catch {
|
|
Write-WTLog " Expand-Archive failed: $_" 'ERROR'
|
|
}
|
|
}
|
|
|
|
if (Test-Path $maZip) {
|
|
$maDest = 'C:\MitutoyoApp'
|
|
Write-WTLog "Extracting $maZip -> $maDest"
|
|
try {
|
|
if (-not (Test-Path $maDest)) { New-Item -Path $maDest -ItemType Directory -Force | Out-Null }
|
|
Expand-Archive -Path $maZip -DestinationPath $maDest -Force
|
|
} catch {
|
|
Write-WTLog " Expand-Archive failed: $_" 'WARN'
|
|
}
|
|
}
|
|
|
|
if (Test-Path $regGz) {
|
|
$regOut = Join-Path $env:TEMP 'hklm-wow-mitutoyo.reg'
|
|
Write-WTLog "Decompressing $regGz -> $regOut"
|
|
try {
|
|
$inGz = [IO.File]::OpenRead($regGz)
|
|
$gz = New-Object IO.Compression.GZipStream($inGz, [IO.Compression.CompressionMode]::Decompress)
|
|
$out = [IO.File]::Create($regOut)
|
|
$gz.CopyTo($out)
|
|
$out.Close(); $gz.Close(); $inGz.Close()
|
|
Write-WTLog "Importing reg file via reg.exe /s"
|
|
& reg.exe import $regOut 2>&1 | ForEach-Object { Write-WTLog " reg: $_" }
|
|
Write-WTLog " reg import exit $LASTEXITCODE"
|
|
Remove-Item $regOut -Force -ErrorAction SilentlyContinue
|
|
} catch {
|
|
Write-WTLog " reg import failed: $_" 'ERROR'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 3: Per-machine calibration ISO (mount + apply via cal Setup.exe)
|
|
# ============================================================================
|
|
# Cal ISOs are keyed by asset_tag. Read machine-number.txt to pick the right
|
|
# ISO. Each cal ISO is ~1.7MB and contains a tiny Mitutoyo wrapper Setup.exe
|
|
# plus data/*.txt compensation tables for the bay's specific probe + serial.
|
|
$mnPath = 'C:\Enrollment\machine-number.txt'
|
|
$asset = $null
|
|
if (Test-Path -LiteralPath $mnPath) {
|
|
$asset = (Get-Content -LiteralPath $mnPath -First 1 -ErrorAction SilentlyContinue).Trim()
|
|
}
|
|
if (-not $asset) {
|
|
Write-WTLog "machine-number.txt missing or empty - skipping calibration apply" 'WARN'
|
|
} else {
|
|
$calDir = Join-Path $stagingRoot 'calibrations'
|
|
$candidate = Get-ChildItem $calDir -Filter "CAL-${asset}_*.iso" -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if (-not $candidate) {
|
|
Write-WTLog "No cal ISO matched CAL-${asset}_*.iso in $calDir - skipping" 'WARN'
|
|
} else {
|
|
Write-WTLog "Mounting cal ISO: $($candidate.FullName)"
|
|
try {
|
|
$img = Mount-DiskImage -ImagePath $candidate.FullName -PassThru -ErrorAction Stop
|
|
Start-Sleep -Seconds 2
|
|
$calDrive = ($img | Get-Volume).DriveLetter
|
|
Write-WTLog " mounted at ${calDrive}:"
|
|
$calSetup = "${calDrive}:\Setup.exe"
|
|
if (Test-Path -LiteralPath $calSetup) {
|
|
Write-WTLog " running cal Setup.exe (may prompt - VB6 wrapper, same vintage as main installer)"
|
|
# Cal ISO Setup.exe is tiny (135KB) - if it prompts, user has to click through.
|
|
# Acceptable today; future: dark-deploy the data/*.txt files directly into
|
|
# the FormTracePak data dir + skip Setup.exe.
|
|
$p = Start-Process -FilePath $calSetup -WorkingDirectory "${calDrive}:\" -Wait -PassThru
|
|
Write-WTLog " cal Setup.exe exit $($p.ExitCode)"
|
|
} else {
|
|
Write-WTLog " cal Setup.exe not found on ISO at $calSetup" 'WARN'
|
|
}
|
|
Dismount-DiskImage -ImagePath $candidate.FullName -ErrorAction SilentlyContinue | Out-Null
|
|
Write-WTLog " cal ISO dismounted"
|
|
} catch {
|
|
Write-WTLog " Mount-DiskImage failed: $_" 'ERROR'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 4: OpenText auto-start at login (HostExplorer "WJ Shopfloor" session)
|
|
# ============================================================================
|
|
$autoStartLib = Join-Path $PSScriptRoot '..\Shopfloor\lib\Set-OpenTextAutoStart.ps1'
|
|
if (Test-Path -LiteralPath $autoStartLib) {
|
|
Write-WTLog "Calling $autoStartLib"
|
|
& $autoStartLib
|
|
} else {
|
|
Write-WTLog "Set-OpenTextAutoStart.ps1 not found at $autoStartLib - OpenText auto-start NOT configured" 'WARN'
|
|
}
|
|
|
|
if (Get-Command Send-PxeStatus -ErrorAction SilentlyContinue) {
|
|
$finalStatus = if ($rc -eq 0) { 'in_progress' } else { 'failed' }
|
|
$finalErr = if ($rc -ne 0) { "Install-FromManifest exit $rc" } else { '' }
|
|
Send-PxeStatus -Stage '09-Setup-WaxAndTrace: complete' -StageIndex 4 -StageTotal 8 -Status $finalStatus -Error_ $finalErr
|
|
}
|
|
|
|
Write-WTLog "================================================================"
|
|
Write-WTLog "=== WaxTrace Setup session end ==="
|
|
Write-WTLog "================================================================"
|
|
|
|
try { Stop-Transcript | Out-Null } catch {}
|