我有运行命令的示例代码,但它不起作用(只是打开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();
哪里有问题?
答案 0 :(得分:6)
您需要添加/ C
CMD.exe的正确语法是
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();
答案 1 :(得分:1)
您不需要使用cmd.exe配合...
我想这应该可以帮到你......
string strCmdLine =
"\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe \"";
var parmaters = "google.com";
System.Diagnostics.Process.Start(strCmdLine, parmaters);
答案 2 :(得分:0)
您需要参数“/ 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();