推 shinywong:你的 Comments 基本上可以不用寫... 01/09 18:17
我想要寫一支程式, 利用外部指令來取得指令的執行結果...
public static string ExecuteCommand(string Command)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + Command;
p.StartInfo.UseShellExecute = false; //關閉Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向標準輸入
p.StartInfo.RedirectStandardOutput = true; //重定向標準輸出
p.StartInfo.RedirectStandardError = true; //重定向錯誤輸出
p.StartInfo.CreateNoWindow = true; //設置不顯示窗口
p.Start(); //啟動
return p.StandardOutput.ReadToEnd();
}
然後我就可以 string Result = ExecuteCommand("dir C:\");
因為它呼叫的是 cmd.exe 所以它的DIR的結果就會是中文的...
可是我希望它的結果是英文的...
我知道還有一個叫 command.com 也是 DOS視窗... 而且是全英文...
但是我把那個 cmd.exe 改成 command.com 就沒辦法執行..
請問有沒有人可以指點一下... ^^"
__yroj
--
因為不是每個人都有女朋友
所以上帝賜給我們十根手指頭
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.248.5.97