C-Sharp 调用命令行

带控制台

string strCmdText = "/C ffplay \"D:\\dynamic wallpaper\\2.mp4\"";
System.Diagnostics.Process.Start("cmd.exe", strCmdText);
string strCmdText = "\"D:\\dynamic wallpaper\\2.mp4\"";
System.Diagnostics.Process.Start(@"D:\my-tools\ffmpeg-4.3.1-win32\static\bin\ffplay.exe", strCmdText);

隐藏控制台

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C ffplay \"D:\\dynamic wallpaper\\2.mp4\"";
process.StartInfo = startInfo;
process.Start();
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = @"D:\my-tools\ffmpeg-4.3.1-win32\static\bin\ffplay.exe";
startInfo.Arguments = "\"D:\\dynamic wallpaper\\2.mp4\"";
process.StartInfo = startInfo;
process.Start();
posted @ 2020-09-23 21:05  Ajanuw  阅读(343)  评论(0编辑  收藏  举报