[英]How to run a command in C# Console Application using switches in the command?
I am trying to run a command in my C# console app but keeps failing with我正在尝试在我的 C# 控制台应用程序中运行命令,但一直失败
'w:\start' is not recognized as an internal or external command, operable program or batch file.
The drive gets mapped successfully and can run the command with just using @"/CW:\Setup.exe"
but as you can see in the below code there are switches now:驱动器已成功映射,并且可以仅使用
@"/CW:\Setup.exe"
运行命令,但正如您在下面的代码中看到的那样,现在有开关:
System.Diagnostics.Process.Start("cmd.exe", @"/c w:\start /wait setup.exe /auto upgrade /NoReboot /DynamicUpdate disable /showoobe None /Telemetry Disable").WaitForExit();
And when I run the app it gives me the above error?当我运行该应用程序时,它给了我上述错误? Am I missing something here?
我在这里错过了什么吗?
Thanks谢谢
Assuming setup.exe
is on W:
drive, you can write:假设
setup.exe
在W:
驱动器上,您可以编写:
System.Diagnostics.Process.Start("cmd.exe", @"/c start /wait ""Some Title"" w:\setup.exe /auto upgrade /NoReboot /DynamicUpdate disable /showoobe None /Telemetry Disable").WaitForExit();
Indeed, using the start
command line command with options you need to specify a title for the console window, between start
options and the file to execute and its own options.实际上,使用带有选项的
start
命令行命令,您需要在start
选项和要执行的文件及其自己的选项之间指定控制台 window 的标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.