一個(gè)exe文件比如說是aaa.exe 這個(gè)是由一個(gè)控制臺(tái)應(yīng)用程序編譯而成 aaa.exe需要2個(gè)參數(shù)(即main函數(shù)中的args)我現(xiàn)在想在C#中 調(diào)用這個(gè)aaa.exe 并且傳入2個(gè)參數(shù) 具體代碼應(yīng)該怎么寫? 是用Process么?如果要傳入的參數(shù)中 有空格 怎么辦。
2 回答

FFIVE
TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("ping -n 2 123.125.114.131");
p.StandardInput.WriteLine("exit");
這是調(diào)用cmd.exe來執(zhí)行CMD命令的,你看看能不能對(duì)你有用
- 2 回答
- 0 關(guān)注
- 195 瀏覽
添加回答
舉報(bào)
0/150
提交
取消