2012-10-29 37 views
0

讀PowerShell腳本的退出代碼我想從C#代碼如何從C#代碼

Add-Content D:\f.txt "Import Module" 
Add-Content D:\f.txt "Remove Module" 
Add-Content D:\f.txt "The End" 
exit 4 

執行下列電源shell腳本,我可以從C#代碼成功執行腳本。

我想讓我的C#程序讀取從powershell返回的退出值(即4)。

你能告訴我怎樣才能實現它嗎? 注:我是C#和PowerShell的新手。

+7

請向我們展示C#代碼如何執行腳本。 Powershell代碼本身對回答您的問題並不感興趣。 –

+0

[如何通過c#讀取PowerShell退出代碼]可能的重複(http://stackoverflow.com/questions/12895503/how-to-read-powershell-exit-code-via-c-sharp) –

回答