我嘗試從 WPF 應用程序(在App.xaml.cs中)調用 powershell 腳本,如下所示:private void Application_Startup(object sender, StartupEventArgs e){ var process = new Process(); process.StartInfo.FileName = "powershell.exe"; process.StartInfo.Arguments = @"\\WIN-SRV-2019\Betreuung-Release\Install.ps1"; process.Start(); process.WaitForExit(); // ...}結果,powershell 窗口很快打開,然后在不執(zhí)行腳本的情況下立即關閉。當我在命令行 (CMD) 上執(zhí)行以下命令時:C:\Users\Entwicklung>powershell \\WIN-SRV-2019\Betreuung-Release\Install.ps1...一切正常。腳本按預期執(zhí)行。我究竟做錯了什么?
從 WPF 應用程序調用 powershell 腳本不執(zhí)行腳本
慕碼人2483693
2022-12-31 14:02:33