|
|
C# Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ Process pro= new Process(); pro.OutputDataReceived += new DataReceivedEventHandler(pro_OutputDataReceived); ProcessStartInfo psi = new ProcessStartInfo("test.cmd"); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; pro.StartInfo = psi; pro.Start(); pro.BeginOutputReadLine(); pro.WaitForExit(); } private void pro_OutputDataReceived(object sender, DataReceivedEventArgs e) { // e.Data liefert dir den Output als string } |

|
|
C# Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Process pro = new Process(); pro.OutputDataReceived += new DataReceivedEventHandler(pro_OutputDataReceived); ProcessStartInfo psi = new ProcessStartInfo("cmd.exe"); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; pro.StartInfo = psi; pro.Start(); pro.BeginOutputReadLine(); pro.WaitForExit(); psi.CreateNoWindow = true; psi.Arguments = "call D:\\tools\\svn-win32-1.4.5\\bin\\log\\beep.bat"; |
|
|
C# Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Process pro = new Process(); pro.OutputDataReceived += new DataReceivedEventHandler(pro_OutputDataReceived); ProcessStartInfo psi = new ProcessStartInfo(@"D:\tools\svn-win32-1.4.5\bin\log\beep.bat"); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; psi.CreateNoWindow = true; pro.StartInfo = psi; pro.Start(); // hier startest du den prozess. in deinem fall die beep.bat pro.BeginOutputReadLine(); pro.WaitForExit(); |
|
|
C# Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Process pro = new Process(); pro.OutputDataReceived += new DataReceivedEventHandler(pro_OutputDataReceived); ProcessStartInfo psi = new ProcessStartInfo("cmd.exe"); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; psi.CreateNoWindow = true; pro.StartInfo = psi; pro.Start(); pro.BeginOutputReadLine(); pro.WaitForExit(); |
|
|
C# Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
using System.Diagnostics; public void meinefunktion() { Process pro= new Process(); pro.OutputDataReceived += new DataReceivedEventHandler(pro_OutputDataReceived); ProcessStartInfo psi = new ProcessStartInfo(@"D:\tools\svn-win32-1.4.5\bin\log\beep.bat"); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; pro.StartInfo = psi; pro.Start(); pro.BeginOutputReadLine(); pro.WaitForExit(); } private void pro_OutputDataReceived(object sender, DataReceivedEventArgs e) { Console.WriteLine(e.Data); } |
Quoted
noch eine frage: dieser code stürzt beim ausführen ab... was ist daran schuld? das WaitForExit()? es wird aber noch nicht mal eine dosbox geöffnet.
|
|
C# Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Process pro = new Process(); pro.OutputDataReceived += new DataReceivedEventHandler(pro_OutputDataReceived); ProcessStartInfo psi = new ProcessStartInfo(@"C:\WINNT\system32\cmd.exe"); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; psi.CreateNoWindow = true; psi.Arguments = "/c \"ipconfig\""; pro.StartInfo = psi; pro.Start(); pro.BeginOutputReadLine(); pro.WaitForExit(); void pro_OutputDataReceived(object sender, DataReceivedEventArgs e) { try { if (e.Data != null && e.Data != "") { //txtLabel.Invoke(new EventHandler(delegate { txtLabel.AppendText(e.Data.ToString()); })); test = e.Data.ToString(); } } catch (Exception o) { MessageBox.Show(o.Message + o.Source + o.InnerException); } } |
|
|
C# Quellcode |
1 |
test = e.Data.ToString(); |

|
|
C# Quellcode |
1 |
pro.WaitForExit(); |
