{"record":{"id":"841fbe05d2654dc2","repo":"BornToBeRoot/NETworkManager","slug":"process-could-not-be-started-puttycontrol-xaml","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/PuTTYControl.xaml.cs","lineNumber":222,"sourceCode":"\n                        IsConnected = true;\n\n                        // Resize after short delay — not applied immediately\n                        await Task.Delay(250);\n\n                        ResizeEmbeddedWindow();\n\n                        // Correct DPI if PuTTY started at a different DPI than our panel\n                        var currentPanelDpi = NativeMethods.GetDpiForWindow(WindowHost.Handle);\n\n                        if (initialWindowDpi != currentPanelDpi)\n                            NativeMethods.TrySendDpiChangedMessage(_appWin, initialWindowDpi, currentPanelDpi);\n                    }\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":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/BornToBeRoot/NETworkManager/blob/2780d65469917a296dbc15f206107d72e2d0115c/Source/NETworkManager/Controls/PuTTYControl.xaml.cs#L204-L240","documentation":"PuTTYControl.Connect() starts the PuTTY executable with Process.Start(info) and embeds its window. Process.Start returns null when the process could not be launched (e.g. the file does not exist or the shell could not execute it), and the control then throws this generic Exception, which is caught and shown in a message box. It signals that no PuTTY process was created, so the session cannot be embedded.","triggerScenarios":"Process.Start returns null in Connect() — which happens when the configured ApplicationFilePath (e.g. putty.exe) is missing, invalid, blocked, or cannot be executed on the current system.","commonSituations":"Portable NETworkManager installs where PuTTY.exe was not downloaded or was moved; an empty or wrong path in the PuTTY application settings; antivirus or AppLocker blocking putty.exe; running on a machine where the bundled/executable path does not resolve.","solutions":["Open Settings > PuTTY (or the session settings) and set the correct full path to putty.exe; verify the file exists at that path.","Use the bundled PuTTY via Scripts/external or download the official putty.exe and point ApplicationFilePath at it.","Check antivirus/AppLocker logs to confirm putty.exe is not being blocked from executing.","Reconnect the tab after fixing the path — the control supports Reconnect() which will retry Connect()."],"exampleFix":"// before (caller-side check)\nsession.ApplicationFilePath = \"putty.exe\";\n// after\nvar puttyPath = @\"C:\\Tools\\putty.exe\";\nif (!File.Exists(puttyPath))\n    throw new FileNotFoundException(\"putty.exe not found\", puttyPath);\nsession.ApplicationFilePath = puttyPath;","handlingStrategy":"validation","validationCode":"var path = sessionInfo.ApplicationFilePath;\nbool canStart = !string.IsNullOrWhiteSpace(path) && File.Exists(path);","typeGuard":"static bool HasExecutable(string path) => !string.IsNullOrWhiteSpace(path) && File.Exists(path) && Path.GetExtension(path).Equals(\".exe\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try\n{\n    await Connect();\n}\ncatch (Exception ex) when (ex.Message == \"Process could not be started!\")\n{\n    MessageBox.Show($\"PuTTY executable not found or blocked: {settings.PuTTYPath}\", \"Error\");\n}","preventionTips":["Validate the PuTTY executable path in Settings before opening a PuTTY tab.","Ship or download putty.exe alongside the app and resolve its path at startup.","Check antivirus/AppLocker policies on machines where sessions fail to start.","Surface a settings link in the error dialog so users fix the path quickly."],"tags":["csharp","process-start","putty","external-tool"],"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"}