首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从PsExec读取输出

从PsExec读取输出
EN

Stack Overflow用户
提问于 2017-07-12 07:36:19
回答 1查看 436关注 0票数 0

嗨,iam试图使用PsExec工具在我的远程机器上执行ipconfig,但是我得到了错误代码0的Psexec工具退出。

这是我用的代码

代码语言:javascript
复制
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工具读取输出?我在做什么错误?

EN

回答 1

Stack Overflow用户

发布于 2022-02-01 10:52:14

很难检索输出代码,它似乎没有包含在错误代码中。我也遇到了同样的问题,但我决定找一个解决办法--将结果写入temp文件,从那里读取,删除该文件。

致以敬意,

亚历克斯

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45051266

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档