2026-06-04 20:20:41 +03:30
|
|
|
package runner
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
2026-06-04 21:21:04 +03:30
|
|
|
"os/exec"
|
2026-06-04 20:20:41 +03:30
|
|
|
"path/filepath"
|
|
|
|
|
)
|
|
|
|
|
|
2026-06-04 21:21:04 +03:30
|
|
|
// ClearAECrashState removes the markers After Effects uses to decide it crashed,
|
|
|
|
|
// so the blocking "Crash Repair Options" (Safe Mode) dialog never appears on a
|
|
|
|
|
// headless launch. Two parts:
|
2026-06-04 20:20:41 +03:30
|
|
|
//
|
2026-06-04 21:21:04 +03:30
|
|
|
// 1. SCRPriorState.json in each AE prefs version dir (session crash-recovery state).
|
|
|
|
|
// 2. HKCU\Software\Adobe\After Effects\AppStates — AE writes a per-session GUID
|
|
|
|
|
// subkey on startup and removes it on a clean exit; a leftover one (after a
|
|
|
|
|
// kill/crash) triggers Safe Mode. reg.exe is a Windows built-in (no external
|
|
|
|
|
// dep / cgo), so we shell out to it.
|
|
|
|
|
//
|
|
|
|
|
// Targeted (vs. wiping all prefs) so the node keeps its AE preferences. Safe no-op
|
|
|
|
|
// on non-Windows (APPDATA unset).
|
2026-06-04 20:20:41 +03:30
|
|
|
func ClearAECrashState() {
|
|
|
|
|
appData := os.Getenv("APPDATA")
|
|
|
|
|
if appData == "" {
|
2026-06-04 21:21:04 +03:30
|
|
|
return // non-Windows / dev
|
2026-06-04 20:20:41 +03:30
|
|
|
}
|
2026-06-04 21:21:04 +03:30
|
|
|
|
|
|
|
|
// 1. session crash-recovery files
|
2026-06-04 20:20:41 +03:30
|
|
|
base := filepath.Join(appData, "Adobe", "After Effects")
|
2026-06-04 21:21:04 +03:30
|
|
|
if entries, err := os.ReadDir(base); err == nil {
|
|
|
|
|
for _, e := range entries {
|
|
|
|
|
if e.IsDir() {
|
|
|
|
|
_ = os.Remove(filepath.Join(base, e.Name(), "SCRPriorState.json"))
|
|
|
|
|
}
|
2026-06-04 20:20:41 +03:30
|
|
|
}
|
|
|
|
|
}
|
2026-06-04 21:21:04 +03:30
|
|
|
|
|
|
|
|
// 2. registry session/crash state
|
|
|
|
|
_ = exec.Command("reg", "delete", `HKCU\Software\Adobe\After Effects\AppStates`, "/f").Run()
|
2026-06-04 20:20:41 +03:30
|
|
|
}
|