File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Source/NETworkManager/ViewModels Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -577,8 +577,12 @@ private void TryFindExecutable()
577577 if ( realPwshPath != null )
578578 applicationFilePath = realPwshPath ;
579579 }
580- else if ( string . IsNullOrEmpty ( applicationFilePath ) )
580+
581+ // Fallback to Windows PowerShell
582+ if ( string . IsNullOrEmpty ( applicationFilePath ) )
581583 {
584+ Log . Warn ( "Failed to resolve pwsh.exe path. Falling back to Windows PowerShell." ) ;
585+
582586 applicationFilePath = ApplicationHelper . Find ( PowerShell . WindowsPowerShellFileName ) ;
583587 }
584588
@@ -624,7 +628,13 @@ private string FindRealPwshPath(string path)
624628
625629 string output = process . StandardOutput . ReadToEnd ( ) ;
626630
627- process . WaitForExit ( ) ;
631+ if ( ! process . WaitForExit ( 10000 ) )
632+ {
633+ process . Kill ( ) ;
634+ Log . Warn ( "Timeout while trying to resolve real pwsh path." ) ;
635+
636+ return null ;
637+ }
628638
629639 if ( string . IsNullOrEmpty ( output ) )
630640 return null ;
@@ -634,13 +644,14 @@ private string FindRealPwshPath(string path)
634644 . Replace ( @"\n" , string . Empty )
635645 . Replace ( "\r \n " , string . Empty )
636646 . Replace ( "\n " , string . Empty )
637- . Replace ( "\r " , string . Empty )
638- . Trim ( ) ;
647+ . Replace ( "\r " , string . Empty ) ;
639648
640- return output ;
649+ return output . Trim ( ) ;
641650 }
642- catch
651+ catch ( Exception ex )
643652 {
653+ Log . Error ( $ "Failed to resolve real pwsh path: { ex . Message } ") ;
654+
644655 return null ;
645656 }
646657 }
You can’t perform that action at this time.
0 commit comments