diff --git a/src/shared/Core/WslUtils.cs b/src/shared/Core/WslUtils.cs index 1db63d329..977677d6e 100644 --- a/src/shared/Core/WslUtils.cs +++ b/src/shared/Core/WslUtils.cs @@ -195,8 +195,16 @@ public static int GetWindowsSessionId(IFileSystem fs) const string script = @"(Get-Process -ID $PID).SessionId"; using (Process proc = CreateWindowsShellProcess(fs, WindowsShell.PowerShell, script)) { - proc.Start(); - proc.WaitForExit(); + try + { + proc.Start(); + proc.WaitForExit(); + } + catch + { + // Unable to start the process, return unknown session ID + return -1; + } if (proc.ExitCode == 0) {