3
我有一個程序,從事件處理程序調用PowerShell腳本。 powershell腳本是由第三方提供的,我沒有任何控制權。閱讀PowerShell進度條輸出C#
PowerShell腳本使用PowerShell進度條。我需要閱讀powershell腳本的進度,但是由於進度條的原因,System.Management.Automation命名空間不會將其視爲輸出。是否有可能從外部程序讀取PowerShell進度條的值?
Process process = new Process();
process.StartInfo.FileName = "powershell.exe"; process.StartInfo.Arguments = String.Format("-noexit -file \"{0}\"", scriptFilePath); process.Start();
腳本是作爲獨立運行還是作爲Powershell ISE運行?此外,您是否需要知道每一刻的價值,還是隻有當它達到100%時纔會關心? – Wossname
每時每刻。我目前通過我在上面所做的編輯開始它。 – user3010406
如果您想對Progress流進行一些編程控制,請不要啓動'powershell.exe',而應使用'System.Management.Automation' –