BornToBeRoot/NETworkManager · error · Exception

Process could not be started!

Error message

Process could not be started!

What it means

PowerShellControl.Connect starts a powershell.exe process and embeds its console window. If the process handle exists but the main window handle could not be obtained (process failed to actually start or exited immediately), the code throws Exception('Process could not be started!'), which is then shown in a message box.

Solutions

  1. Verify the configured PowerShell executable path exists and points to a valid powershell.exe/pwsh.exe
  2. Run powershell.exe -NoProfile from a shell to confirm it starts cleanly
  3. Check settings for invalid PowerShell parameters/execution policy that crash startup
  4. Reinstall/repair Windows PowerShell or PowerShell 7; check antivirus/EDR blocks

Example fix

// before
var process = Process.Start(startInfo);
// after
var process = Process.Start(startInfo);
if (process == null || !process.WaitForInputIdle(5000))
    throw new Exception($"Process could not be started: {startInfo.FileName}");
Defensive patterns

Strategy: try-catch

Validate before calling

string exe = settings.PowerShellLocation; // or default
if (!File.Exists(exe)) throw new FileNotFoundException("PowerShell executable not found", exe);

Type guard

bool CanStartPowerShell(string path) => !string.IsNullOrWhiteSpace(path) && File.Exists(path);

Try / catch

try { Connect(); }
catch (Exception ex) when (ex.Message == "Process could not be started!") { MessageBox.Show("PowerShell could not be started. Check the executable path and installation."); }

Prevention

When it happens

Trigger: Process.Start succeeded in name but the PowerShell process exited instantly or never created a window — e.g. powershell.exe not found/path wrong, execution policy or profile errors crashing startup, corrupted PowerShell installation, or insufficient permissions.

Common situations: Broken PowerShell SDK install; antivirus blocking powershell.exe; invalid settings pointing at a non-existent PowerShell executable or bad command-line args; environment issues on locked-down corporate machines.

Related errors


AI-assisted analysis of BornToBeRoot/NETworkManager@2780d65469 (2026-09-12). Data as JSON: /api/errors/7831fae9193630f5. Report an issue: GitHub.

Appendix: source

Thrown at Source/NETworkManager/Controls/PowerShellControl.xaml.cs:208

                    NativeMethods.SetWindowLongPtr(_appWin, NativeMethods.GWL_STYLE, new IntPtr(style));

                    IsConnected = true;

                    // Resize after short delay — not applied immediately
                    await Task.Delay(250);

                    ResizeEmbeddedWindow();

                    // Correct font if conhost started at a different DPI than our panel
                    var currentPanelDpi = NativeMethods.GetDpiForWindow(WindowHost.Handle);

                    if (initialWindowDpi != currentPanelDpi)
                        NativeMethods.TryRescaleConsoleFont((uint)_process.Id, (double)currentPanelDpi / initialWindowDpi);
                }
            }
            else
            {
                throw new Exception("Process could not be started!");
            }
        }
        catch (Exception ex)
        {
            if (!_closed)
                // Use built-in message box because we have visual issues in the dragablz window
                MessageBox.Show(ex.Message, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);
        }

        IsConnecting = false;
    }

    private void Process_Exited(object sender, EventArgs e)
    {
        // This happens when the user exit the process
        IsConnected = false;
    }

View on GitHub (pinned to 2780d65469)