Jump to content

Get Output from cmd.exe


Recommended Posts

Hello,

i want to get the Output from a cmd.exe process.

Ive tried this:

$text = ControlCommand ("C:\WINDOWS\system32\cmd.exe", "", "Edit2", "GetLine",0)

$text = ControlGetText("C:\WINDOWS\system32\cmd.exe","","")

and

$f = Run("cmd.exe", "C:\WINDOWS\system32\",@SW_MINIMIZE,$STDOUT_CHILD)
Local $data = ""
While True
$data &= StdoutRead($f)
MsgBox(0,"Tets",$data)
Sleep(25)
WEnd

None of them work for me.

Is there a Syntax problem? Do i need different parameters or attributes?

Thank you.

Link to comment
Share on other sites

Does something like this work?

#include <Constants.au3>

$foo = Run(@ComSpec, "", @SW_MINIMIZE, $STDERR_CHILD + $STDOUT_CHILD)

Local $line

While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

While 1
    $line = StderrRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDERR read:", $line)
Wend
Link to comment
Share on other sites

did a dir to edit box

#include <Constants.au3>
#include <GUIConstantsEx.au3>
$HG_tracert = GUICreate("Test", 450, 355, 200, 125, -1, -1)
$tcrmb = GUICtrlCreateEdit("Test", 5, 5, 445, 300)
GUISetBkColor(0x8899ff)
GUISetState(@SW_SHOW)
$output = Run(@ComSpec & " /c dir", "", @SW_HIDE, $STDOUT_CHILD)
$tcrtout = ""
$tcrcatch = ""
While 1
    $tcrtout &= StdoutRead($output)
    If $tcrtout <> $tcrcatch Then
        GUICtrlSetData($tcrmb, $tcrtout)
        $tcrcatch = $tcrtout
    EndIf
    If @error Then ExitLoop
WEnd
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

If your program is running the cmd.exe, you could pipe the output out to a file:

Run(@ComSpec & " /c dir > output.txt", @ScriptDir)

Basically the same as doing this in a command prompt:

dir > output.txt
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...