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(); } }