CMD操作函数代码

一、命名空间

using System.Diagnostics;

二、函数代码

        /// <summary>
        /// CMD运行应用程序
        /// </summary>
        /// <param name="appName">应用程序名</param>
        /// <param name="arg">参数</param>
        private void CmdProcess(string appName, string arg)
        {
            Process process = new Process();
            process.StartInfo.FileName = "cmd.exe";
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.Arguments = "/c" + appName + arg;
            process.Start();
            process.WaitForExit();
            if(process.HasExited)
            {
                process.Close();
            }
        }

 

posted @ 2017-02-22 22:33  空白凌乱感  阅读(1152)  评论(0编辑  收藏  举报