您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

运行命令提示符命令

运行命令提示符命令

这就是从C#运行shell命令所要做的全部

string strCmdText;
strCmdText= "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);

这是为了隐藏cmd窗口。

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 copy /b Image1.jpg + Archive.rar Image2.jpg";
process.StartInfo = startInfo;
process.Start();

重要的是,该论点始于/C否则将不起作用。斯科特·弗格森(Scott Ferguson)怎么说:“执行由字符串指定的命令,然后终止。”

其他 2022/1/1 18:13:35 有536人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶