我最近试图执行以下行;
string strCmdText;
strCmdText = "netstat -np TCP | find " + quote + number + quote + "";
System.Diagnostics.Process.Start("netstat.exe", strCmdText);
Logs.Write("LISTEN_TO(" + Registry_val1.Text + ")", strCmdText);
Run Code Online (Sandbox Code Playgroud)
现在要做的基本上是找到所有包含“ 80”的TCP端口,并将它们显示在我的定制日志系统中,该系统将在我的文件夹中创建一个日志。
这个.txt中的LISTEN_TO(80)-{date_time} .txt应该包含命令发出的文本,但是我得到的只是时间。
我如上所述调试了此命令,不幸的是,我所知道的只是CMDtext设置正确,并且我的日志记录系统正常运行,让我别无选择,一旦启动查询,NETSTAT可能会关闭?
希望我提供了足够的信息,因为这是我的第一篇文章。
问候,
有限公司
由于描述不明确,这是我尝试执行的其他相同代码,但是仍然只能得到一些时间。
const string quote = "\"";
Process p = new Process();
p.StartInfo.FileName = "cmd";
p.StartInfo.Arguments = "netstat -np TCP | find " + quote + number + quote + "";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
String output = p.StandardOutput.ReadToEnd();
Logs.Write("LISTEN_TO(" …Run Code Online (Sandbox Code Playgroud)