# Ensure-PCDMISFrontEnd.ps1 - create C:\GE PC-DMIS FRONT END + grant operator write. # # WHY: PCDToIGES.exe (geaofi\Scripts) writes its error log to # C:\GE PC-DMIS FRONT END\PCDToIGES.ERR in its catch block. If that dir does # not exist, ANY PCDToIGES failure becomes an unhandled DirectoryNotFoundException # that CRASHES the export and MASKS the real error (observed on freshly imaged CMM # bays - the legacy "GE PC-DMIS FRONT END" front-end setup is not part of imaging, # so the dir is absent). Creating it + making it operator-writable lets the real # error log instead of crashing, and gives the front-end a working dir. # # Run as administrator. Idempotent - safe to re-run; re-asserts the ACL. $ErrorActionPreference = 'Continue' $dir = 'C:\GE PC-DMIS FRONT END' $logDir = 'C:\Logs\CMM' New-Item -ItemType Directory -Path $logDir -Force -EA SilentlyContinue | Out-Null $ts = Get-Date -Format 'yyyyMMdd-HHmmss' $log = Join-Path $logDir "pcdmis-frontend-$ts.log" function Log($m){ $line = "[{0}] {1}" -f (Get-Date -Format 'HH:mm:ss'), $m; Write-Host $line; Add-Content -Path $log -Value $line -EA SilentlyContinue } Log "==== Ensure-PCDMISFrontEnd on $env:COMPUTERNAME ====" if (Test-Path -LiteralPath $dir) { Log "Dir already exists: $dir" } else { try { New-Item -ItemType Directory -Path $dir -Force -EA Stop | Out-Null; Log "Created $dir" } catch { Log "ERROR: could not create $dir - $($_.Exception.Message)"; exit 1 } } # Operator (locked-down, non-admin) must be able to write PCDToIGES.ERR here. # Modify = read/write/create/delete. SIDs, not names, to stay locale-independent. foreach ($sid in '*S-1-5-32-545','*S-1-5-11') { # BUILTIN\Users, NT AUTHORITY\Authenticated Users & icacls "$dir" /grant "${sid}:(OI)(CI)M" /T /C 2>&1 | Out-Null } Log "Granted Users + Authenticated Users Modify on $dir" # Verify an operator-style write works $probe = Join-Path $dir '.write-test' try { Set-Content -LiteralPath $probe -Value 'ok' -EA Stop; Remove-Item -LiteralPath $probe -EA SilentlyContinue; Log "Write-test OK" } catch { Log "WARN: write-test failed - $($_.Exception.Message)" } Log "==== DONE ====" Write-Host "" Write-Host "C:\GE PC-DMIS FRONT END ready. Re-run the measurement; if PCDToIGES still" -ForegroundColor Green Write-Host "errors, the real cause now logs to $dir\PCDToIGES.ERR" -ForegroundColor Green exit 0