[英]How to read exit code of powershell script from C# code
我想从C#代码执行以下Power Shell脚本
Add-Content D:\f.txt "Import Module"
Add-Content D:\f.txt "Remove Module"
Add-Content D:\f.txt "The End"
exit 4
我可以从C#代码成功执行脚本。
我希望我的C#程序读取Powershell返回的退出值(即4)。
您能告诉我如何实现吗? 注意:我是C#和powershell的新手。
与如何通过c#读取PowerShell退出代码相同的问题,似乎您需要尝试其他方法,例如PowerShell.Streams.Error或Runspace.RunspaceStateInfo,而不是退出代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.