@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