c#调用Dos命令(超捷)

  string[] cmd = new string[] { @"cd C:\Program Files\华光科技\超捷网络4.2", "YJClient.exe $StartFromXinWen$ admin 00" };
                Process p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.CreateNoWindow = true;
                p.Start();
                p.StandardInput.AutoFlush = true;
                for (int i = 0; i < cmd.Length; i++)
                {
                    p.StandardInput.WriteLine(cmd[i].ToString());
                }
                p.StandardInput.WriteLine("exit");
                string strRst = p.StandardOutput.ReadToEnd();
                p.WaitForExit();
                p.Close();
posted @ 2011-04-27 16:58  郑文亮  阅读(489)  评论(2编辑  收藏  举报