CMM: add Register-PCDMIS-COM.bat desktop helper for post-license COM regserver
PC-DMIS COM must be registered for goCMM to connect, but Pcdlrn.exe /regserver no-ops until PC-DMIS is licensed - which is a manual post-image step (clmadmin.exe). So we cannot register at imaging time. Instead 09-Setup-CMM drops a self-elevating one-click helper on the SupportUser desktop (a pre-existing profile; avoids 06-OrganizeDesktop's Public-desktop sweep). The tech runs it after activating the license; safe to re-run. Falls back to Public Desktop if the SupportUser profile is absent. Copy happens before the Step 3 staging cleanup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -314,6 +314,32 @@ if (Test-Path -LiteralPath $restoreScript) {
|
||||
Write-CMMLog "Restore-CMM.ps1 not found at $restoreScript - skipping settings restore" 'WARN'
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Step 2.5: drop Register-PCDMIS-COM.bat on the SupportUser desktop
|
||||
# ============================================================================
|
||||
# PC-DMIS COM must be registered for goCMM to connect, but /regserver no-ops
|
||||
# until PC-DMIS is licensed - which happens manually post-image (clmadmin.exe).
|
||||
# So we cannot register at imaging time; instead leave a one-click helper the
|
||||
# tech runs AFTER activating the license. SupportUser is a pre-existing profile
|
||||
# (see 03-ShellDefaults), so its Desktop exists now. Public Desktop would get
|
||||
# reorganized by 06-OrganizeDesktop's sweep, so target SupportUser directly;
|
||||
# fall back to Public Desktop only if the SupportUser profile is absent.
|
||||
$regBat = Join-Path $stagingRoot 'Register-PCDMIS-COM.bat'
|
||||
if (Test-Path -LiteralPath $regBat) {
|
||||
$deskTargets = @()
|
||||
if (Test-Path 'C:\Users\SupportUser') { $deskTargets += 'C:\Users\SupportUser\Desktop' }
|
||||
else { $deskTargets += 'C:\Users\Public\Desktop' }
|
||||
foreach ($d in $deskTargets) {
|
||||
try {
|
||||
if (-not (Test-Path $d)) { New-Item -Path $d -ItemType Directory -Force | Out-Null }
|
||||
Copy-Item -LiteralPath $regBat -Destination (Join-Path $d 'Register-PCDMIS-COM.bat') -Force
|
||||
Write-CMMLog "Staged Register-PCDMIS-COM.bat -> $d"
|
||||
} catch { Write-CMMLog "Failed to stage Register-PCDMIS-COM.bat to ${d}: $_" 'WARN' }
|
||||
}
|
||||
} else {
|
||||
Write-CMMLog "Register-PCDMIS-COM.bat not in staging ($regBat) - desktop helper NOT placed" 'WARN'
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Step 3: Conditional cleanup of the bootstrap staging dir
|
||||
# ============================================================================
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
@echo off
|
||||
REM ============================================================================
|
||||
REM Register-PCDMIS-COM.bat - register the PC-DMIS COM / automation server.
|
||||
REM
|
||||
REM WHY: goCMM connects to PC-DMIS over COM. If the COM server is not
|
||||
REM registered, goCMM throws "Object reference not set to an instance of an
|
||||
REM object" at startup (it calls Type.GetTypeFromProgID on the PC-DMIS ProgID,
|
||||
REM gets null, then Activator.CreateInstance(null) -> ArgumentNullException).
|
||||
REM
|
||||
REM IMPORTANT: PC-DMIS must be LICENSED FIRST. /regserver does NOT register the
|
||||
REM COM server until a valid license is present. Activate the license with
|
||||
REM clmadmin.exe, THEN run this. Safe to re-run any time goCMM stops connecting.
|
||||
REM
|
||||
REM Needs admin - this script self-elevates via UAC.
|
||||
REM ============================================================================
|
||||
|
||||
REM --- self-elevate if not already running as admin ---
|
||||
net session >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo Requesting administrator rights...
|
||||
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
||||
exit /b
|
||||
)
|
||||
|
||||
echo ================================================================
|
||||
echo Register PC-DMIS COM server (run AFTER licensing PC-DMIS)
|
||||
echo ================================================================
|
||||
echo.
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
set "FOUND="
|
||||
for %%D in (
|
||||
"C:\Program Files\Hexagon"
|
||||
"C:\Program Files (x86)\Hexagon"
|
||||
"C:\Program Files\WAI"
|
||||
"C:\Program Files (x86)\WAI"
|
||||
) do (
|
||||
if exist %%~D (
|
||||
for /f "delims=" %%F in ('dir /b /s "%%~D\Pcdlrn.exe" 2^>nul') do (
|
||||
set "FOUND=1"
|
||||
echo Registering: %%F
|
||||
"%%F" /regserver
|
||||
if !errorlevel! equ 0 (echo OK) else (echo regserver returned !errorlevel!)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
echo.
|
||||
if not defined FOUND (
|
||||
echo ERROR: Pcdlrn.exe not found. Is PC-DMIS installed?
|
||||
) else (
|
||||
echo Done.
|
||||
echo If goCMM still errors, confirm PC-DMIS is LICENSED ^(clmadmin.exe^) and
|
||||
echo that you ran this AFTER activating the license, then re-run.
|
||||
)
|
||||
echo.
|
||||
pause
|
||||
Reference in New Issue
Block a user