嗨,iam试图使用PsExec工具在我的远程机器上执行ipconfig,但是我得到了错误代码0的Psexec工具退出。
这是我用的代码
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.Domain = txtDomainName.Text;
p.StartInfo.UserName = txtUser.Text;
p.StartInfo.Password = secure;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + @"PSTools\psexec.exe";
p.StartInfo.Arguments = String.Format(@"\\{0} /accepteula cmd.exe ipconfig /all > c:\output.log", ipAddress);
p.Start();
p.WaitForExit();
string output = string.Empty;
while (!p.StandardError.EndOfStream)
{
output += p.StandardError.ReadToEnd().ToString();
}如何使用psexec工具读取输出?我在做什么错误?
发布于 2022-02-01 10:52:14
很难检索输出代码,它似乎没有包含在错误代码中。我也遇到了同样的问题,但我决定找一个解决办法--将结果写入temp文件,从那里读取,删除该文件。
致以敬意,
亚历克斯
https://stackoverflow.com/questions/45051266
复制相似问题