获取命令提示符 c#

时间:2021-05-05 17:37:58

标签: c# cmd

以下代码在本地机器上执行一个.exe文件,并根据同目录下的一个.obj文件生成一个新文件.ifc.obj(新的)和 .ifc 应该具有相同的名称(没问题)。

if (clicked) {
  Process p = new Process();
  p.StartInfo.FileName = "cmd.exe";

  p.StartInfo.WorkingDirectory = "C:\...";

  string arg1;

  arg1 = "@/c  command" // run .exe appliaction

  p.StartInfo.Arguments = arg1;

  p.Start();

  p.StartInfo.CreateNoWindow = true;

  p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

  p.WaitForExit();
}

如果用户再次单击按钮(代码再次运行),则会出现一个新的 cmd 并告诉他该文件已经存在。他是否想覆盖: (y/n) 将是这种情况下的论点。

现在我想捕获那个新的 cmd 并用“是/否”窗口替换它,这样用户就不会看到它。这怎么可能?

0 个答案:

没有答案
相关问题