0
代碼的目標是:將秒的整數值傳入Powershell腳本,然後用於告訴Powershell腳本等待,然後重新啓動控制檯應用程序。運行獨立於C#應用程序的Powershell腳本
問題:Powershell腳本實例存在於應用程序內部。這意味着當我想退出應用程序並保持腳本運行時,應用程序一直等到腳本完成。
PowerShell psExec = PowerShell.Create();
psExec.AddCommand(@powershellScriptLocation);
psExec.AddArgument(Convert.ToInt32(CalculateTimeToWait().TotalSeconds));
psExec.Invoke();
你想安排一個工作爲或使用PowerShell的後臺工作 – 4c74356b41
你可以簡單地嘗試使用'的Process.Start()'和使用'PowerShell.exe'啓動腳本。 –