我是新手,遇到点麻烦,向各位请教:
    使用C#里面的process启动cmd命令行,在cmd中启动其他程序,该程序启动后不到10秒便会自动关闭,不知道是什么原因。以下是我写的代码:        public void Login(string userID, string userPassWord, string projectName, string subprojectName, string path)
        {            accountName = userID;
            accoutPassword = userPassWord;
            project = projectName;
            subpro = subprojectName;            // Create the directory if it does not exist.
            DirectoryInfo pathName = new DirectoryInfo(path);
            if (!pathName.Exists)
            {
                pathName.Create();
                targetDirection = pathName.FullName + "\\";
            }
            else
            {
                targetDirection = pathName.FullName + "\\";
            }            string progremPath = @"cd /d C:\Program Files\eng\v2_2b2\bin";
            string initial_cmd = "  -user=" + accountName + " -pass=" + accoutPassword + " -proj=" + project + " -sub=" + subpro + " -def=" + targetDirection;
            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 = false;
            p.Start();
            p.StandardInput.WriteLine(progremPath);
            p.StandardInput.WriteLine(initial_cmd);
            if (!Check__Start())
            {
                MessageBox.Show(" cannot start!");
                Process.GetCurrentProcess().Kill();
            }
            else 
            {
                MessageBox.Show(" start!");
            }
        }
        
        private bool Check_Start()
        {
            //check if the program has started
            //search 10 times,5 seconds per time
            //if not find, exit
            int searching_times = 1;
            do
            {
                foreach (Process thisproc in System.Diagnostics.Process.GetProcesses())
                {
                    if (thisproc.ProcessName == "javaw")
                    {
                        return true;
                    }
                }
                Thread.Sleep(5000);
                searching_times++;
            }while (searching_times < 10);
            return false;
        }