[英]Execute CMD Command by C# winform app?
I have sample code to run command but its not working ( just opens CMD ) without executing the command 我有运行命令的示例代码,但它不工作(只是打开CMD)而不执行命令
string strCmdLine =
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe " +
"--load-extension=\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\toolbar-GC\"";
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();
where is problem ? 哪里有问题?
You need to add a /C 你需要添加一个/ C.
Correct syntax for CMD.exe is CMD.exe的正确语法是
CMD.EXE /c command
CMD.EXE / c命令
string strCmdLine =
"/C C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe " +
"--load-extension=\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\toolbar-GC\"";
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();
You don't need to use cmd.exe mate... 你不需要使用cmd.exe配合...
I guess this should do the job for you... 我想这应该为你做的工作......
string strCmdLine =
"\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe \"";
var parmaters = "google.com";
System.Diagnostics.Process.Start(strCmdLine, parmaters);
you need the parameter "/c" 你需要参数“/ c”
string strCmdLine =
"/c C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe " +
"--load-extension=\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\toolbar-GC\"";
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.