c#获取远程PsExec netstat命令的输出。 [英] c# get output of remote PsExec netstat command.

查看:181
本文介绍了c#获取远程PsExec netstat命令的输出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要编写一个返回netstat输出的程序。



我把PsExec.exe放在另一台机器上。

没有perrmission问题。



Hi, I'm tring to code a program that returns netstat output.

I put a PsExec.exe on the other machine.
There are no perrmission issues.

Process netStat = new Process();
netStat.StartInfo.UseShellExecute = false;
netStat.StartInfo.CreateNoWindow = true;
netStat.StartInfo.FileName = @"cmd.exe";
netStat.StartInfo.Arguments = @"\\10.190.167.200\r10\SilentInstall\Tools\PsExec.exe netstat";
netStat.StartInfo.RedirectStandardOutput = true;
netStat.Start();
string output = netStat.StandardOutput.ReadToEnd();





即使我看到命令运行netstat,输出返回



任何想法?

谢谢,Imbaro



even that i see the command run the netstat, the output returns ""

Any ideas?
Thanks, Imbaro

推荐答案

用/ C前缀你的参数行表示:运行Command然后终止。



当然注释掉我的测试行:c:/ dir并取消你的注释。



Prefix your argument line with "/C " what indicates: Run Command and then terminate.

And of course comment out my test line with: "c:/ dir" and uncomment yours.

         Process netStat = new Process();
         netStat.StartInfo.UseShellExecute = false;
         netStat.StartInfo.CreateNoWindow = true;
         netStat.StartInfo.FileName = @"cmd.exe";
//         netStat.StartInfo.Arguments = @"C/ \\10.190.167.200\r10\SilentInstall\Tools\PsExec.exe netstat";
         netStat.StartInfo.Arguments = @"/C dir";
         netStat.StartInfo.RedirectStandardOutput = true;
         netStat.Start();
         string output = netStat.StandardOutput.ReadToEnd();


这篇关于c#获取远程PsExec netstat命令的输出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆