Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: 79137913 en 2 Diciembre 2013, 15:32 pm



Título: [FUNCION] Autoit CMD Prompt
Publicado por: 79137913 en 2 Diciembre 2013, 15:32 pm
HOLA!!!

Jugando con autoit cree esta pequeña suite de funciones para trabajar con CMD:
Código
  1. ;Creado por 79137913
  2. Global $cmdpid
  3. Global $cmdresponse
  4.  
  5. ;~ _iniciarCMD()
  6. ;~ _sendCMDCommand("ping 127.0.0.1",2)
  7. ;~ MsgBox(0,"",$cmdresponse)
  8. ;~ _sendCMDCommand("cd ..",1)
  9. ;~ MsgBox(0,"",$cmdresponse)
  10. ;~ _sendCMDCommand("cd ..",1)
  11. ;~ MsgBox(0,"",$cmdresponse)
  12. ;~ _CerrarCMD()
  13. func _SendCMDCommand($command,$timeoutlimit);Envia un comando CMD y devuelve la respuesta, timeout es en segundos
  14.    StdinWrite($cmdpid,$command)
  15.    StdinWrite($cmdpid,@CRLF)
  16. ;StdinWrite($cmdpid)
  17.    Local $data
  18. Local $response
  19. Local $timeout
  20. $data = ""
  21.    While True
  22.    sleep(100)
  23.        $data &= StdoutRead($cmdpid)
  24.        If $data <> "" Then
  25. $response=$response & $data
  26. $data=""
  27. $timeout=0
  28. $timeout=$timeout+1
  29. if $timeout=$timeoutlimit*10 then ExitLoop
  30.    WEnd
  31.    $cmdresponse = $response
  32. func _CerrarCMD();Cerrar CMD
  33.   StdinWrite($cmdpid)
  34. Func _IniciarCMD();Inicializar CMD
  35.    $cmdpid = Run("C:\Windows\system32\cmd.exe",@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)

GRACIAS POR LEER!!!


Título: Re: [FUNCION] Autoit CMD Prompt
Publicado por: Danyfirex en 2 Diciembre 2013, 16:14 pm
Gracias por la función es muy útil.  no uses Dim ;)

saludos