第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 WPF 應用程序調用 powershell 腳本不執(zhí)行腳本

從 WPF 應用程序調用 powershell 腳本不執(zhí)行腳本

C#
慕碼人2483693 2022-12-31 14:02:33
我嘗試從 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í)行。我究竟做錯了什么?
查看完整描述

1 回答

?
元芳怎么了

TA貢獻1798條經驗 獲得超7個贊

我終于發(fā)現了問題所在。我不得不添加-executionpolicy unrestricted到參數中:


private void Application_Startup(object sender, StartupEventArgs e)

{

  var process = new Process();

  process.StartInfo.FileName = "powershell.exe";

  process.StartInfo.Arguments = @"-executionpolicy unrestricted \\WIN-SRV-2019\Betreuung-Release\Install.ps1";


  process.Start();

  process.WaitForExit();

  // ...

}


查看完整回答
反對 回復 2022-12-31
  • 1 回答
  • 0 關注
  • 164 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號