Jump to content

_ReturnBatch


m0nk3yI3unz
 Share

Recommended Posts

Heya all! Just a little script I came up with because I got annoyed at the fact that I could execute batch commands but could never get the feedback from them. Problem solved. Enjoy!

-I3unz

P.S. - If there is a command for this that I somehow missed, or there is a script like this, just tell me. Thanks!

;==== _DOSFeedback ========================================
;
;   Name:           _DOSFeedback($sCommand[, $sDir])
;   Author:         M0nk3y_I3unz
;   Attributes:     $sCommand - The Batch command to be 
;                               processed.
;                   $sDir] -    The directory in which the
;                               temporary file is stored.
;   Return Values:  String -    The batch command output
;                   0 -         Error
;   Error Codes:    0 -         No Error
;                   1 -         The temporary file already
;                               exists.
;                   2 -         The temporary file doens't
;                               exist after having batch
;                               file write to it.
;                   3 -         Temporary file contains no
;                               data.
;                   4 -         Deleting of temporary file
;                               failed.
;
;==========================================================

Func _DOSFeedback($sCommand,$sDir)
        If not $sDir Then
            $sDir = "C:\WINDOWS\"
        Else
            if not stringright($sDir,1) = "\" then
                $sDir &= "\"
            EndIf
        EndIf
    $sPath = $sDir&"tempAU3Feedback.txt"
        if not fileexists($sPath) Then
            RunWait(@COMSPEC & " /c "&$sCommand&" > "&$sPath)
            if fileexists($sPath) Then
                $sContents = fileread($sPath)
                if $sContents Then
                    return $sContents
                    if FileDelete($sPath) = 0 Then
                        SetError(4)
                    EndIf
                Else
                    return 0
                    SetError(3)
                EndIf
            Else
                Return 0
                setError(2)
            EndIf
        Else
            Return 0
            setError(1)
        EndIf
EndFunc
Edited by m0nk3yI3unz

Monkeh.

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