Hallo,
ich habe eine batch datei die in ienen Text Fenster ausgeben möchte.
Dioe BAtch Datei führt Abruf durch und es kommen mehrere Meldungen.
Leider zeigt er mir nur die erste Meldung an
Ausgabe im cmd Fenster wenn ich die Datei so starte
# Lade Datei vom bliblablub System herunter
Starte Service ...
Datei 'N:\Daten\test.TXT' wurde heruntergeladen
Beendet mit Status (0): Aktion wurde erfolgreich durchgeführt.
Drücken Sie eine beliebige Taste . . .
kann mir jmand eine Tipp geben das ich die Anzeige in meine Text Fenster bekomme?
ich habe eine batch datei die in ienen Text Fenster ausgeben möchte.
Dioe BAtch Datei führt Abruf durch und es kommen mehrere Meldungen.
Leider zeigt er mir nur die erste Meldung an
Ausgabe im cmd Fenster wenn ich die Datei so starte
# Lade Datei vom bliblablub System herunter
Starte Service ...
Datei 'N:\Daten\test.TXT' wurde heruntergeladen
Beendet mit Status (0): Aktion wurde erfolgreich durchgeführt.
Drücken Sie eine beliebige Taste . . .
kann mir jmand eine Tipp geben das ich die Anzeige in meine Text Fenster bekomme?
C#-Quellcode
- private void cmdClose_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void cmdStart_Click(object sender, EventArgs e)
- {
- Process cmd = new Process();
- cmd.OutputDataReceived += new DataReceivedEventHandler(cmd_OutputDataReceived);
- cmd.StartInfo.FileName = @"C:\test.cmd";
- cmd.StartInfo.UseShellExecute = false;
- cmd.StartInfo.RedirectStandardOutput = true;
- cmd.StartInfo.RedirectStandardInput = true;
- cmd.StartInfo.CreateNoWindow = true;
- cmd.Start();
- cmd.BeginOutputReadLine();
- }
- private void cmd_OutputDataReceived(object sender, DataReceivedEventArgs e)
- {
- try
- {
- if (e.Data != null && e.Data != "")
- {
- textBox.Invoke(new EventHandler(delegate {textBox.AppendText(e.Data); }));
- }
- }
- catch (Exception o)
- {
- MessageBox.Show(o.Message + o.Source + o.InnerException);
- }
- }