Board index » Visual Studio » Capturing Command Line Utility Output in VB 6

Capturing Command Line Utility Output in VB 6

Visual Studio290
Hi there



Got a need to run a command line utility and capture the output in my VB6

program.



I know I could used the WScript object and get the STDOUT data via a

textstream (all nice and neat)...HOWEVER....



Using the .exec method causes a DOS window to flick on/off.



Does anyone know a way that I could use WScript to run a command line

utility (so I can get the output in an ordered fashion) but NO window

showing.



The .run method (like shell) allows for a hidden window...but not easy to

get the output (or is it? Anyone know a good way...please let me know).



Any help much appreciated



Many thanks



Mike Finister


-
 

Re:Capturing Command Line Utility Output in VB 6

Hi Mike --



You can use redirection and pipes in a Shell, if you invoke a secondary command

processor at the same time, which of course can be hidden. Something like:



Shell Environ("comspec") & " /c someprog.exe>stdout.txt"



Another option would be to write your own console application, capable of reading

stdin, and redirect/pipe straight to that. (Recommend hitting

www.vbadvance.com">www.vbadvance.com if that appeals.)



Later... Karl

--

[Microsoft Basic: 1976-2001, RIP]







Mike Finister <REMOVEnewsgroupME@finisterTO.netUSE>wrote:

Quote
Hi there



Got a need to run a command line utility and capture the output in my VB6

program.



I know I could used the WScript object and get the STDOUT data via a

textstream (all nice and neat)...HOWEVER....



Using the .exec method causes a DOS window to flick on/off.



Does anyone know a way that I could use WScript to run a command line

utility (so I can get the output in an ordered fashion) but NO window

showing.



The .run method (like shell) allows for a hidden window...but not easy to

get the output (or is it? Anyone know a good way...please let me know).



Any help much appreciated



Many thanks



Mike Finister







-

Re:Capturing Command Line Utility Output in VB 6

use zero in the second flag for no window, 4 for a window, 6 for a minimized

window.



"Mike Finister" <REMOVEnewsgroupME@finisterTO.netUSE>wrote in message

Quote
Hi there



Got a need to run a command line utility and capture the output in my VB6

program.



I know I could used the WScript object and get the STDOUT data via a

textstream (all nice and neat)...HOWEVER....



Using the .exec method causes a DOS window to flick on/off.



Does anyone know a way that I could use WScript to run a command line

utility (so I can get the output in an ordered fashion) but NO window

showing.



The .run method (like shell) allows for a hidden window...but not easy to

get the output (or is it? Anyone know a good way...please let me know).



Any help much appreciated



Many thanks



Mike Finister









-