RosettaCodeData/Task/Get-system-command-output/VBScript/get-system-command-output.vbs

21 lines
524 B
Text
Raw Permalink Normal View History

2026-04-30 12:34:36 -04:00
For Each line In ExecCmd("ipconfig /all")
Wscript.Echo line
Next
'Execute the given command and return the output in a text array.
Function ExecCmd(cmd)
'Execute the command
Dim wso : Set wso = CreateObject("Wscript.Shell")
Dim exec : Set exec = wso.Exec(cmd)
Dim res : res = ""
'Read all result text from standard output
Do
res = res & VbLf & exec.StdOut.ReadLine
Loop Until exec.StdOut.AtEndOfStream
'Return as a text array
ExecCmd = Split(Mid(res,2),vbLf)
End Function