我正在尝试使用我在互联网上找到的这段代码,运行远程 netstat :(在 C# 中)
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:\\Windows\\System32\\PsExec.exe";
proc.StartInfo.Arguments = @"\\" + server + " -u username -p password netstat";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.WaitForExit();
StreamReader myStreamReader = proc.StandardOutput;
string s = myStreamReader.ReadToEnd();
proc.Close();
proc.Dispose();
该程序在这些行中是堆栈的: proc.WaitForExit(); StreamReader myStreamReader = proc.StandardOutput;
有人对我有解决方案吗?谢谢!