2011-02-03 87 views
1

可能重複:
How To: Execute command line in C#, get STD OUT results如何在C#中運行命令並從中檢索數據?

你好,

在我的C#應用​​程序,我想運行的命令PROMT命令,並希望其產量和maipulate其輸出。如果需要,要關閉該過程並顯示錯誤或適當的消息。要停止進程,我必須在命令提示符下按「F4」鍵,直到進程停止或被殺死,它必須是活着的。 。這如果任何機構可以幫助我解決我的問題會很高興

感謝

回答

1

您是否需要這樣的

ProcessStartInfo startInfo = new ProcessStartInfo 
      { 
       CreateNoWindow = false, 
       UseShellExecute = false, 
       FileName = @"program", 
       WindowStyle = ProcessWindowStyle.Normal, 
       Arguments = "agruments" 
      }; 

      using (Process exeProcess = Process.Start(startInfo)) 
      { 
       if (exeProcess != null) exeProcess.WaitForExit(); 
      } 
0

您可以嘗試使用ProcessSystem.Diagnostics下推出並獲得輸出 能否請您闡述一下什麼類型的命令和它的意圖,對部分未明確

+0

由於此線程被標記爲「CLOSED」,因此我認爲我無法在此線程中與您分享更多內容。但我需要的不僅僅是這些。請參閱http://stackoverflow.com/questions/4884175/manipulate-the-output-receiving-from-command-run-and-act-accordingly-c瞭解更多avout我的問題。它不僅僅像執行「dir」ike命令,檢索輸出並且該過程已經是「退出」。它不僅僅是這樣。我需要你的指導,請盡我所能幫助你。 - 謝謝 – Tvd 2011-02-03 09:17:07

相關問題