Idea is to have a more convenient way of getting one-liner output than fiddling with runProgram+readProgramString syntax all the time.
Note: only tested with simple commands.
Code: Select all
Procedure.s outputOf(externalCommand.s) ;; for one-liners with one-line output :)
externalCommand = ReplaceString(externalCommand,"'",Chr(34))
outputStream = RunProgram("cmd" , "/c " + externalCommand, "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
Repeat
o.s = ReadProgramString(outputStream )
i+1
Until o.s <> "" Or i > 3
ProcedureReturn o
EndProcedure
;;; Examples
OpenConsole("Test")
PrintN( OutputOf("netsh interface ip show interface 12 | find 'State '" ))
PrintN( OutputOf("ping www.google.com -n 1" ))
PrintN( OutputOf("ipconfig | find 'IPv4' " ))
Delay(999)