如何在命令中使用开关 运行 C# 控制台应用程序中的命令?

How to run a command in C# Console Application using switches in the command?

我正在尝试 运行 我的 C# 控制台应用程序中的命令,但一直失败

'w:\start' is not recognized as an internal or external command, operable program or batch file.

驱动器已成功映射,并且可以 运行 仅使用 @"/C W:\Setup.exe" 命令,但正如您在下面的代码中看到的,现在有开关:

System.Diagnostics.Process.Start("cmd.exe", @"/c w:\start /wait setup.exe /auto upgrade /NoReboot /DynamicUpdate disable /showoobe None /Telemetry Disable").WaitForExit();

当我 运行 应用程序时,它会出现上述错误?我在这里遗漏了什么吗?

谢谢

假设setup.exeW:驱动器上,你可以这样写:

System.Diagnostics.Process.Start("cmd.exe", @"/c start /wait ""Some Title"" w:\setup.exe /auto upgrade /NoReboot /DynamicUpdate disable /showoobe None /Telemetry Disable").WaitForExit();

确实,使用带有选项的start命令行命令,您需要在start选项和要执行的文件及其自身选项之间为控制台window指定标题.