CMM: add PC-DMIS + combined CMM backup/restore + diagnostic scripts
Adds the PC-DMIS settings/probe backup-restore set alongside the existing goCMM scripts, plus a single combined CMM backup and the diagnostics built while debugging the live bays: - Backup-PCDMISSettings / Install-PCDMISSettings: capture+restore PC-DMIS registry + data/probe/cal files per installed version (2016/2019/2026). Hardened from real-bay failures: detect install dir via Program Files fallback; capture compens.dat (not just comp.dat) + interfac.dll; identify the controller by hash-matching interfac.dll to its source DLL AND reading the PE OriginalFilename (covers rename-without-copy); EXCLUDE the whole Homepage state (Recent/Favorites/DetailsView) which null-refs PC-DMIS on launch via stale routine paths; restore routes HKCU into the target user's hive (-TargetUser ShopFloor), fails loud on a non-backup path, and applies the legacy->new FQDN rewrite across reg + data files incl .bas. - Backup-CMM: one wrapper running goCMM + PC-DMIS (all versions) into one per-CMM folder + index, for staging on PXE and restore-by-machine-number. - Clear-PCDMISRecent: fixes the Homepage recent-list NullReferenceException crash on an already-broken bay. - pcdmis-probe-debug / Export-PCDMISCrashEvents: diagnostics for the custom-probe-not-showing and crash investigations. - Modify-PCDMISRights / Grant-FullControl: grant the operator the registry + filesystem access PC-DMIS needs under lockdown. - Install-goCMMSettings: add .bas to the FQDN-rewrite include list. Not yet wired into 09-Setup-CMM auto-restore - staging + the gated restore block come next. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<#
|
||||
Clear-PCDMISRecent.ps1
|
||||
|
||||
Fixes the PC-DMIS startup crash:
|
||||
System.NullReferenceException
|
||||
at Adapter.Service.Recent.Models.RecentExecutedItem.LoadRealNode()
|
||||
at Adapter.Service.Recent.Models.RecentExecutedFiles.LoadAllWhenReady()
|
||||
|
||||
Cause: the Homepage "Recent Executed Files" list contains absolute routine
|
||||
paths (S:\..., C:\geaofi\LocalProgramCopies\...). When a path does not resolve
|
||||
in the running user's context (drive not visible, cache not yet rebuilt, file
|
||||
gone), PC-DMIS dereferences a null while async-loading the list and crashes on
|
||||
launch. A list carried over from another bay (e.g. a settings restore) is the
|
||||
common trigger.
|
||||
|
||||
Fix: delete the Recent (and Favorites) Homepage state for every user profile
|
||||
and every PC-DMIS version. PC-DMIS rebuilds an empty list on next start.
|
||||
|
||||
Run as ADMINISTRATOR (to reach all user profiles).
|
||||
Output: C:\Logs\CMM\pcdmis-clearrecent-<PC>-<ts>.log
|
||||
|
||||
Params:
|
||||
-RecentOnly only clear the Recent list, keep Favorites
|
||||
-User <name> only this user's profile (default: all profiles)
|
||||
#>
|
||||
param(
|
||||
[switch]$RecentOnly,
|
||||
[string]$User
|
||||
)
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$ts = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||
$dir = 'C:\Logs\CMM'
|
||||
New-Item -ItemType Directory -Path $dir -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$log = Join-Path $dir "pcdmis-clearrecent-$env:COMPUTERNAME-$ts.log"
|
||||
function Log($m){ Write-Host $m; $m | Out-File -FilePath $log -Append }
|
||||
|
||||
Log "==== Clear PC-DMIS Recent/Favorites on $env:COMPUTERNAME at $(Get-Date) ===="
|
||||
|
||||
# which user profiles
|
||||
$userDirs = @()
|
||||
if ($User) {
|
||||
if (Test-Path "C:\Users\$User") { $userDirs += "C:\Users\$User" } else { Log "User profile C:\Users\$User not found" }
|
||||
} else {
|
||||
$userDirs = (Get-ChildItem 'C:\Users' -Directory -ErrorAction SilentlyContinue).FullName
|
||||
}
|
||||
|
||||
$targets = @('Homepage\Recent\RecentExecutedFiles.xml')
|
||||
if (-not $RecentOnly) { $targets += 'Homepage\Favorites\Favorites.xml' }
|
||||
|
||||
$deleted = 0; $scanned = 0
|
||||
foreach ($u in $userDirs) {
|
||||
foreach ($vendor in 'Hexagon','WAI') {
|
||||
$base = Join-Path $u "AppData\Local\$vendor\PC-DMIS"
|
||||
if (-not (Test-Path $base)) { continue }
|
||||
foreach ($vdir in (Get-ChildItem $base -Directory -ErrorAction SilentlyContinue)) {
|
||||
$scanned++
|
||||
foreach ($rel in $targets) {
|
||||
$f = Join-Path $vdir.FullName $rel
|
||||
if (Test-Path $f) {
|
||||
try { Remove-Item $f -Force -ErrorAction Stop; $deleted++
|
||||
Log " DELETED $f"
|
||||
} catch { Log " FAILED $f : $($_.Exception.Message)" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log ""
|
||||
Log "Scanned $scanned PC-DMIS version folder(s) across $($userDirs.Count) profile(s); deleted $deleted file(s)."
|
||||
Log "PC-DMIS will rebuild an empty recent list on next launch."
|
||||
Write-Host ""
|
||||
if ($deleted -gt 0) { Write-Host "Cleared $deleted stale Homepage file(s). Relaunch PC-DMIS - the crash should be gone." -ForegroundColor Green }
|
||||
else { Write-Host "Nothing to clear (no RecentExecutedFiles.xml found). If it still crashes, the cause is elsewhere - grab the event log." -ForegroundColor Yellow }
|
||||
Log "Log: $log"
|
||||
Reference in New Issue
Block a user