Jump to content

Command line output


Recommended Posts

This is an example of running a command and retrieving data from cmd (may help you)

Local $iCommand='ping 8.8.8.8'
Local $iReturn=_RunWait($iCommand)
MsgBox(262144, $iCommand, $iReturn)

Func _RunWait($sCommand)
    ConsoleWrite("! RUN: " & $sCommand & @CRLF)
    Local $sOutput, $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand & ' 2>&1', @ScriptDir, @SW_HIDE, 1+2+4) ;$STDERR_CHILD + $STDOUT_CHILD
    Local $itry = 100
    While $itry
        $sLine = StdoutRead($iPID)
        If (@error) Then ExitLoop
        If (Not ProcessExists($iPID)) Then $itry -= 1
        If $sLine <> "" Then
            $sOutput &= $sLine
            ConsoleWrite($sLine)
        EndIf
    WEnd
;~  ConsoleWrite("- OUT: " & @CRLF & $sOutput & @CRLF & @CRLF)
    Return $sOutput
EndFunc   ;==>_RunWait

 

Regards,
 

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...