getting output of command line exe 
Author Message
 getting output of command line exe

Hi,

in a vbs script that I start with cscript, I start a command line exe using

set shell = CreateObject("WScript.Shell")
command = "myprog.exe" + myparameters
return = shell.Run(command, , TRUE)

A dos box pops up and the exe starts, all fine.

It can happen now, that the exe encounters an errors an prints info I need
to stdout and stderr.

But the Dos box is closed immediately after the exe exits, so I cant see the
info. I tried to redirect stdout and stderr to a file, but no file was
generated, and run seems to have no options for this.

Does anybody have an idea??

Thanks,

Stefan



Tue, 29 Apr 2003 03:00:00 GMT  
 getting output of command line exe

Quote:

> Hi,

> in a vbs script that I start with cscript, I start a command line exe
> using

> set shell = CreateObject("WScript.Shell")
> command = "myprog.exe" + myparameters
> return = shell.Run(command, , TRUE)

> A dos box pops up and the exe starts, all fine.

> It can happen now, that the exe encounters an errors an prints info I
> need to stdout and stderr.

> But the Dos box is closed immediately after the exe exits, so I cant
> see the info. I tried to redirect stdout and stderr to a file, but no
> file was generated, and run seems to have no options for this.

> Does anybody have an idea??

> Thanks,

> Stefan

The Run method does not support redirection, but the systems console
command processor does.  So the solution is to use the command processor
to run your console command, something like this ...

set shell = CreateObject("WScript.Shell")
command = "%comspec% myprog.exe " & myparameters & " > out.txt"
return = shell.Run(command, , TRUE)

Unfortunately, this will not catch any text sent to StdErr.  If you're
using NT/2000 exclusively, you can redirect StdErr to a file by adding a
numbered redirection to the 'command' ...

command = "%comspec% myprog.exe " & myparameters & _
          " > out.txt 2> error.txt"

Also, in NT, any errorlevel code set by the program WILL be passed back
to the 'Return' variable, with or without the use of the command
processor.  However, the command processor cannot be used in Win 9x, if
you want to catch an output errorlevel.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Tue, 29 Apr 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. getting output of command line exe

2. Executing command-line EXE and retrieving output

3. Getting command line switches for a VB .EXE

4. How to output error from command line program

5. How to output error from command line program

6. Command line text output

7. command line output - capturing

8. Obtaining output from command line program

9. Getting output of DOS exe's.

10. Sending output to Command Line?

11. View output from command line app

12. Command line output

 

 
Powered by phpBB® Forum Software