- Ensure-PCDMISFrontEnd.ps1/.bat: standalone fix for already-imaged bays - create C:\GE PC-DMIS FRONT END + grant Users/Auth Users Modify. PCDToIGES.exe writes its error log there in its catch block; on a fresh bay the dir is absent (legacy front-end setup isn't part of imaging), so ANY PCDToIGES error becomes an unhandled DirectoryNotFoundException that crashes the export and masks the real cause (confirmed live on a CMM bay). - 09-Setup-CMM Step 2.5b: create that dir + ACL at imaging for every CMM bay. - 09-Setup-CMM Step 2.5: Register-PCDMIS-COM.bat now lands on the Public desktop (visible to operator or SupportUser) instead of SupportUser-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
2.3 KiB
PowerShell
48 lines
2.3 KiB
PowerShell
# 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
|