beeradmoore/dlss-swapper · error · Exception
Process exit code was
Error message
Process exit code was {process.ExitCode} What it means
DLSSSettingsManager.RunRegAdd shells out to an external process (reg add) to change DLSS registry settings and returns true only when the process exits with code 0. Any non-zero exit code triggers this exception, surfacing that the external command failed. Notably, the message uses a non-interpolated string, so the log always reads literally 'Process exit code was {process.ExitCode}' — a string-formatting bug that hides the actual code.
Solutions
- Fix the message to actually interpolate the exit code: use $"Process exit code was {process.ExitCode}" so failures are diagnosable.
- Re-run the operation elevated (as administrator) — HKLM writes usually require admin rights.
- Run the same reg add command manually in a console to see reg.exe's real error output.
- Verify the registry key path and value name/data passed by the Set* caller are valid for the installed DLSS version.
- Check that antivirus/execution policies are not silently blocking reg.exe.
Example fix
// before
throw new Exception("Process exit code was {process.ExitCode}");
// after
throw new Exception($"Process exit code was {process.ExitCode} for: {processInfo.FileName} {processInfo.Arguments}");
Defensive patterns
Strategy: try-catch
Validate before calling
static bool CanWriteRegistry(string keyPath)
{
try
{
using var k = Registry.LocalMachine.OpenSubKey(keyPath, writable: true);
return k != null;
}
catch (UnauthorizedAccessException) { return false; }
catch (SecurityException) { return false; }
} Type guard
static bool Succeeded(Process process) => process is { HasExited: true, ExitCode: 0 }; Try / catch
try
{
DLSSSettingsManager.SetShowDlssIndicator(true);
}
catch (Exception ex) when (ex.Message.StartsWith("Process exit code was"))
{
Logger.Warn(ex, "reg add failed - run the app as administrator to change DLSS settings.");
} Prevention
- Require elevation (or use a manifest with requireAdministrator) when writing HKLM registry values.
- Always interpolate variables in exception messages ($"...") so diagnostics are not lost.
- Capture and log stderr/stdout of external processes, not just the exit code.
- Validate registry key path/value names against the installed DLSS SDK version before invoking reg add.
When it happens
Trigger: Calling SetShowDlssIndicator, SetLogLevel, or SetLoggingWindow when the spawned reg add process exits non-zero: invalid registry value name/data, target key does not exist and reg add cannot create it, insufficient privileges to write HKLM, or the executable is missing/blocked so it fails to run correctly.
Common situations: Running without administrator rights while writing to a protected hive; antivirus or AppLocker blocking reg.exe; typos in value names after a DLSS SDK version change; the ExitCode being a specific reg.exe error (e.g. 1 = access denied / invalid parameters).
Related errors
AI-assisted analysis of beeradmoore/dlss-swapper@ab9b1e2d4b (2026-09-15).
Data as JSON: /api/errors/bfb6899ce7340016.
Report an issue: GitHub.
Appendix: source
Thrown at src/Helpers/DLSSSettingsManager.cs:44
Verb = "runas",
UseShellExecute = true,
CreateNoWindow = true
};
try
{
using (var process = Process.Start(processInfo))
{
if (process is not null)
{
process.WaitForExit();
if (process.ExitCode == 0)
{
return true;
}
throw new Exception("Process exit code was {process.ExitCode}");
}
}
}
catch (Exception err)
{
Logger.Error(err, $"Could not command \"{processInfo.FileName} {processInfo.Arguments}");
}
return false;
}
public bool SetShowDlssIndicator(int value)
{
return RunRegAdd(NGXCORE_REG_KEY, "ShowDlssIndicator", "REG_DWORD", value.ToString(CultureInfo.InvariantCulture));
}
public int GetShowDlssIndicator()
{View on GitHub (pinned to ab9b1e2d4b)