{"record":{"id":"7831fae9193630f5","repo":"BornToBeRoot/NETworkManager","slug":"process-could-not-be-started","errorCode":null,"errorMessage":"Process could not be started!","messagePattern":"Process could not be started!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Source/NETworkManager/Controls/PowerShellControl.xaml.cs","lineNumber":208,"sourceCode":"                    NativeMethods.SetWindowLongPtr(_appWin, NativeMethods.GWL_STYLE, new IntPtr(style));\n\n                    IsConnected = true;\n\n                    // Resize after short delay — not applied immediately\n                    await Task.Delay(250);\n\n                    ResizeEmbeddedWindow();\n\n                    // Correct font if conhost started at a different DPI than our panel\n                    var currentPanelDpi = NativeMethods.GetDpiForWindow(WindowHost.Handle);\n\n                    if (initialWindowDpi != currentPanelDpi)\n                        NativeMethods.TryRescaleConsoleFont((uint)_process.Id, (double)currentPanelDpi / initialWindowDpi);\n                }\n            }\n            else\n            {\n                throw new Exception(\"Process could not be started!\");\n            }\n        }\n        catch (Exception ex)\n        {\n            if (!_closed)\n                // Use built-in message box because we have visual issues in the dragablz window\n                MessageBox.Show(ex.Message, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);\n        }\n\n        IsConnecting = false;\n    }\n\n    private void Process_Exited(object sender, EventArgs e)\n    {\n        // This happens when the user exit the process\n        IsConnected = false;\n    }\n","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/BornToBeRoot/NETworkManager/blob/2780d65469917a296dbc15f206107d72e2d0115c/Source/NETworkManager/Controls/PowerShellControl.xaml.cs#L190-L226","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the configured PowerShell executable path exists and points to a valid powershell.exe/pwsh.exe","Run powershell.exe -NoProfile from a shell to confirm it starts cleanly","Check settings for invalid PowerShell parameters/execution policy that crash startup","Reinstall/repair Windows PowerShell or PowerShell 7; check antivirus/EDR blocks"],"exampleFix":"// before\nvar process = Process.Start(startInfo);\n// after\nvar process = Process.Start(startInfo);\nif (process == null || !process.WaitForInputIdle(5000))\n    throw new Exception($\"Process could not be started: {startInfo.FileName}\");","handlingStrategy":"try-catch","validationCode":"string exe = settings.PowerShellLocation; // or default\nif (!File.Exists(exe)) throw new FileNotFoundException(\"PowerShell executable not found\", exe);","typeGuard":"bool CanStartPowerShell(string path) => !string.IsNullOrWhiteSpace(path) && File.Exists(path);","tryCatchPattern":"try { Connect(); }\ncatch (Exception ex) when (ex.Message == \"Process could not be started!\") { MessageBox.Show(\"PowerShell could not be started. Check the executable path and installation.\"); }","preventionTips":["Validate the PowerShell executable path in settings before connecting","Prefer -NoProfile to avoid startup crashes from user profiles","Verify the PowerShell install works from a shell first","Watch for antivirus/EDR blocking powershell.exe"],"tags":["powershell","process","embedded-console"],"backgroundTag":"command-not-found","analyzedSha":"2780d65469917a296dbc15f206107d72e2d0115c","analyzedAt":"2026-09-12T17:00:17.986Z","contentChangedAt":"2026-09-12T17:00:17.986Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}