Jump to content

Execute to log


Recommended Posts

I need to execute a command line application and have its output stored in a variable. I also don't want this windows displayed.

eg: ping www.google.com

Is there any way to do this?

Which application ?

Yes, there is a way to do this.

Greetz

Greenhorn

Link to comment
Share on other sites

I think, he wants to use the CMD commands :)

$comm = "ping www.google.com"
$PID = Run('"' & @ComSpec & '" /c ' & $comm,"",@SW_HIDE,2)
$txt = ""
While 1
    $txt &= StdoutRead($PID)
    If @error Then ExitLoop
WEnd
$txt = OemToChar($txt)
MsgBox(0, '', $txt)


;===============================================================================
; Name:             OemToChar
; Description:      Wandelt einen ASCII- in einen ANSI-String
; Parameter(s):     $szSrc = String der umgewandelt werden soll
; Requirement(s):   keine
; Return Value(s):  bei Erfolg: umgewandelter String
;                   bei Fehler: "" und @error = 1
; Author(s):        bernd670
;===============================================================================
Func OemToChar($szSrc)
;~ Private Declare Function OemToChar Lib "user32.dll" Alias "OemToCharA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
    Local $placeholder
    For $i = 0 To StringLen($szSrc)
        $placeholder &= "  "
    Next
    Local $lRetVal = DllCall("user32.dll", "long", "OemToChar", "str", $szSrc, "str", $placeholder)
    If IsArray($lRetVal) And $lRetVal[0] = 1 Then
        Return SetError(0, 0, $lRetVal[2])
    EndIf

    Return SetError(1, 0, "")
EndFunc   ;==>OemToChar

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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