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

FFIVE
TA貢獻1797條經驗 獲得超6個贊
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");
這是調用cmd.exe來執行CMD命令的,你看看能不能對你有用
- 2 回答
- 0 關注
- 201 瀏覽
添加回答
舉報
0/150
提交
取消