我想从c#应用程序调用一个从它开始的应用程序的命令行并从中检索统计信息。从.NET应用程序调用命令行
我这样做,但缺少的东西:
ProcessStartInfo psf = new ProcessStartInfo("cmd.exe", "/C time");
psf.WindowStyle = ProcessWindowStyle.Hidden;
psf.RedirectStandardOutput = true;
psf.UseShellExecute = false;
psf.CreateNoWindow = true;
Process p = Process.Start(psf);
StreamReader sr = p.StandardOutput;
p.WaitForExit();
有什么不对?
'CMD/C Time'希望用户输入。除非您提供一些输入,否则它不会关闭。在你的情况下,你隐藏了命令窗口。这使得它看起来像一个输入在隐藏窗口中挂起。 你想要代码做什么? – shahkalpesh 2010-02-21 08:56:09
我不想改变从这个应用程序获得它的时间 – 2010-02-21 08:57:01
你不能使用'DateTime.Now'吗? – shahkalpesh 2010-02-21 08:58:10