如何在C#中使用更多的DOS命令
发布时间:2020-12-15 18:23:31 所属栏目:百科 来源:网络整理
导读:我在DOS中有大约7个命令,我想在我的C#程序中运行它们.我可不可以做: System.Diagnostics.Process.Start("cmd.exe","my more commands here"); ? 编辑: 我正在制作小应用程序将运行g.这现在是正确的吗?: System.Diagnostics.Process.Start("cmd.exe","/k
我在DOS中有大约7个命令,我想在我的C#程序中运行它们.我可不可以做:
System.Diagnostics.Process.Start("cmd.exe","my more commands here"); ? System.Diagnostics.Process.Start("cmd.exe","/k cd C:Alpscompiler /k g++ C:Alps" + project_name + "DebugMain.cpp"); 编译命令: g++ -c C:Alpshere_is_projectnameDebugMain.cpp -o main.o 解决方法cmd.exe /k <command> cmd.exe /c <command> 都是有效的. > / k将执行命令并给你一个空提示(如果你只是想执行反馈,可能在你的应用程序中不太理想.) 如果您要从特定目录执行命令,可以执行以下操作: System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe"); p.StartInfo.Arguments = String.Format(@"/c g++ ""C:Alps{0}DebugMain.cpp""",project_name); p.StartInfo.WorkingDirectory = @"C:Alpscompiler"; p.StartInfo.CreateNoWindow = true; p.StartInfo.ErrorDialog = false; p.Start(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |