110,538
社区成员
发帖
与我相关
我的任务
分享
Process pNet = new Process();
pNet.StartInfo.FileName = "net";
pNet.StartInfo.RedirectStandardOutput = true;
pNet.StartInfo.UseShellExecute = false;
pNet.StartInfo.RedirectStandardInput = false;
string processOutput = string.Empty;
foreach (string s in ipList)
{
pNet.StartInfo.Arguments = @"time \\" + s.Substring(s.IndexOf(',') + 1);
pNet.Start();
processOutput = pNet.StandardOutput.ReadLine();
Console.WriteLine("ServerName:{0} IP:{1} Time:{2}"
, s.Substring(0, s.IndexOf(','))
, s.Substring(s.IndexOf(','))
, processOutput.Substring(processOutput.IndexOf("2012")));
}