public static string Execute(string dosCommand)
{
//return Execute(dosCommand, 10);
try
{
System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
string strCmdLine;
strCmdLine = "/C " + dosCommand;
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
//System.Diagnostics.Process.Start("CMD.exe","/C MD 00New_Folder");
process1.Close();
}
catch (Exception ex)
{
throw ex;
}
return "";
}
调用:
private void btnExe_Click(object sender, EventArgs e)
{
string cmd = this.textBox1.Text.Trim();
this.lblMessage.Text = Lib.CmdHelper.Execute(cmd);
}
效果图:略