R.Wieser
2020-06-17 12:32:35 UTC
Hello all
I'm running a console-based windows program, and need to capture its output.
When I try to use the "exec" method than, nomatter what I try, something
locks up.
My code is basically this:
Set oExec = WshShell.Exec(sCmd)
Do While oExec.Status = 0
WScript.Sleep 100
wscript.echo oExec.stdout.readall
Loop
As the program also outputs on stderr I've changed the above reading of
stdout with
if not oExec.stdout.atendofstream then wscript.echo oExec.stdout.read(1000)
if not oExec.stderr.atendofstream then wscript.echo oExec.stderr.read(1000)
But no matter what I've tried (small buffers, large buffers), at some point
in the output it locks up. :-(
Apart from switching to the "run" method*, what can I do ?
*I've got the "run" method working. But the output capturing needs the use
of "cmd /e ", which in turn causes my screen to go black a few times
(mutiple calls) with no (progress) output on it. Not nice.
Regards,
Rudy Wieser
I'm running a console-based windows program, and need to capture its output.
When I try to use the "exec" method than, nomatter what I try, something
locks up.
My code is basically this:
Set oExec = WshShell.Exec(sCmd)
Do While oExec.Status = 0
WScript.Sleep 100
wscript.echo oExec.stdout.readall
Loop
As the program also outputs on stderr I've changed the above reading of
stdout with
if not oExec.stdout.atendofstream then wscript.echo oExec.stdout.read(1000)
if not oExec.stderr.atendofstream then wscript.echo oExec.stderr.read(1000)
But no matter what I've tried (small buffers, large buffers), at some point
in the output it locks up. :-(
Apart from switching to the "run" method*, what can I do ?
*I've got the "run" method working. But the output capturing needs the use
of "cmd /e ", which in turn causes my screen to go black a few times
(mutiple calls) with no (progress) output on it. Not nice.
Regards,
Rudy Wieser