Announcement

Collapse
No announcement yet.

Shell() Ergebnis abfragen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shell() Ergebnis abfragen

    Ich würde gern wissen, wie ich ein shell commando abfragen kann.

    z.b. mit osql, wenn ein falsches passwort angegeben wird. Geht das überhaupt? Weil ich ja nur einen Integer (processID) wiederbekomme ...
    <br />
    Wäre für jede Hilfe dankbar
    <hr />
    Try
    Me.myID = Shell("osql -U sa -P " & Me.tbChckProgramm.Text, AppWinStyle.Hide, False, -1)
    Catch ex As Exception
    Debug.WriteLine("Mh, nix : " & ex.Message)
    Finally
    Me.lblAusgabe.Text = Me.myID.ToString
    End Try

  • #2
    Hallo,

    ja das geht, wenn <b>RedirectStandardOutput</b> auf True gesetzt wird. Dann kann sich das aufrufende Programm über <b>StandardOutput.ReadToEnd</b> die Ausgabe des aufgerufenen Programms abholen. Das folgende Beispiel demonstriert dies anhand von PING.EXE:
    <code>
    Imports System.Diagnostics
    ...
    Dim p As New Process()
    p.StartInfo.FileName = "ping.exe"
    p.StartInfo.Arguments = "localhost"
    p.StartInfo.UseShellExecute = False
    p.StartInfo.RedirectStandardOutput = True
    p.StartInfo.CreateNoWindow = True
    Dim sOutput As String
    p.Start()
    sOutput = p.StandardOutput.ReadToEnd()
    p.WaitForExit()
    p.Close()
    MessageBox.Show(sOutput)
    </code&gt

    Comment


    • #3
      Wow,

      vielen DAnk funktioniert wunderbar...

      Gruss ethan_hun

      Comment

      Working...
      X