【发布时间】:2020-08-12 18:25:27
【问题描述】:
我有一个由 c# 运行的 powershell 脚本。以下是我的代码:
string data = System.IO.File.ReadAllText(@"C:\Users\user1\Desktop\power.ps1");
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript(data);
IAsyncResult result = PowerShellInstance.BeginInvoke();
while (!result.IsCompleted)
{
Logger.Info("Wait initiated");
Thread.Sleep(5000);
}
}
完成脚本后如何读取退出代码?
【问题讨论】:
标签: c# asp.net .net windows powershell