CMD in Form einfügen

  • VB.NET

Es gibt 26 Antworten in diesem Thema. Der letzte Beitrag () ist von XPcRUSHER.

    michach schrieb:

    Negativ
    Welche Codierungen (Plural!) hast Du denn alle getestet?
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Alle die mir angeboten wurden.

    - ASCII -> Kommen nur normale Fragezeichen
    - BigEndianUnicode -> Kommt überhaupt keine Ausgabe
    - Default - > Kommen nur Gänsefüßchen
    - Unicod -> Kommt überhaupt keine Ausgabe
    - UTF32 -> Kommt überhaupt keine Ausgabe
    - UTF7 -> An den Stellen wo Umlaute sein sollten wird garnichts angezeigt
    - UTF8 -> Werden nur komische Rechtecke als Sonderzeichen angezeigt.

    Ich Starte die Anwendung und gebe einfach mal nur Help in die Adressleiste ein.

    In der "normalen" Windows Konsole werden mir die Umlaute sauber angezeigt.

    Verwendete Schriftart -> Lucida Console
    Die Ausgabe Variiert von der Schriftart die Verwendet wird immer etwas, auch hier habe ich diverse Verwendet, unter anderem "Microsoft Sans Serif" & "Arial"

    Mehr als alle Codierungen für das Encoding der Ausgabe kann ich ja nicht verwenden.

    Ist es vielleicht wirklich garnicht möglich ?
    Hallo @Die Wucht,

    Ich bezweifle das @Lupar dir die Datei noch einmal hochladen kann: Letzte Aktivität Sonntag, 17. Oktober 2010, 02:23

    Aber evt. hilft dir ja: pradeep1210.wordpress.com/2010…-from-vb-net-application/

    Spoiler anzeigen

    VB.NET-Quellcode

    1. Private WithEvents MyProcess As Process
    2. Private Delegate Sub AppendOutputTextDelegate(ByVal text As String)
    3. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    4. Me.AcceptButton = ExecuteButton
    5. MyProcess = New Process
    6. With MyProcess.StartInfo
    7. .FileName = "CMD.EXE"
    8. .UseShellExecute = False
    9. .CreateNoWindow = True
    10. .RedirectStandardInput = True
    11. .RedirectStandardOutput = True
    12. .RedirectStandardError = True
    13. End With
    14. MyProcess.Start()
    15. MyProcess.BeginErrorReadLine()
    16. MyProcess.BeginOutputReadLine()
    17. AppendOutputText("Process Started at: " & MyProcess.StartTime.ToString)
    18. End Sub
    19. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    20. MyProcess.StandardInput.WriteLine("EXIT") 'send an EXIT command to the Command Prompt
    21. MyProcess.StandardInput.Flush()
    22. MyProcess.Close()
    23. End Sub
    24. Private Sub MyProcess_ErrorDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.ErrorDataReceived
    25. AppendOutputText(vbCrLf & "Error: " & e.Data)
    26. End Sub
    27. Private Sub MyProcess_OutputDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.OutputDataReceived
    28. AppendOutputText(vbCrLf & e.Data)
    29. End Sub
    30. Private Sub ExecuteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExecuteButton.Click
    31. MyProcess.StandardInput.WriteLine(InputTextBox.Text)
    32. MyProcess.StandardInput.Flush()
    33. InputTextBox.Text = ""
    34. End Sub
    35. Private Sub AppendOutputText(ByVal text As String)
    36. If OutputTextBox.InvokeRequired Then
    37. Dim myDelegate As New AppendOutputTextDelegate(AddressOf AppendOutputText)
    38. Me.Invoke(myDelegate, text)
    39. Else
    40. OutputTextBox.AppendText(text)
    41. End If
    42. End Sub


    LG Ruerte
    Unfortunately, this Signature is not available in Germany because it may contain music for which GEMA
    has not granted the respective music rights. Sorry about that.