Re: Capture text output of win app
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Wed, 15 Oct 2008 23:51:54 +0200
"Tec92407" <Tec92407@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2376A15F-7E5E-408D-884E-1AADCAD2E0AE@xxxxxxxxxxxxxxxx
"Pegasus (MVP)" wrote:
"Tec92407" <Tec92407@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D8C7E4E9-134C-48E3-B707-3CCCC26F2FB0@xxxxxxxxxxxxxxxx
hi,
I have a custom, non-interactive, windows FTP application (exe) that,
when
executed from the comand line, opens a window and displays program
activity
that would normally be stored in a log file. I believe the app is
written
in
"C" and I don't have the source code so can't change it.
I need to actually save the displayed information into a log file for
review.
I used the following code to try to capture the output but "strOutput"
is
always empty.
==================================
logExec ("app.exe")
Sub logExec(strCommand)
dim objShell, objExecObject, strOutput
Set objshell = wscript.createobject("wscript.shell")
Set objExecObject = objShell.Exec(strCommand)
' use stderr
Do Until objExecObject.StdErr.AtEndOfStream
strOutput = objExecObject.StdErr.ReadLine()
' use stdout
' Do Until objExecObject.StdOut.AtEndOfStream
' strOutput = objExecObject.StdOut.ReadLine()
WriteLog(strOutput)
WScript.Echo strOutput
loop
end sub
================================
I've tried both stdout and stderr but neither work.
Can anyone help?
Thanks.
Try the script below. By the way - if you want your script to be robust
then
you must fully qualify your executable. Calling it "app.exe" is not good
enough.
logExec ("d:\Tools\att.exe c:\")
Sub logExec(strCommand)
Dim objShell, objExecObject
Set objShell = WScript.createobject("wscript.shell")
Set objExecObject = objShell.Exec(strCommand)
Do Until objExecObject.StdOut.AtEndOfStream
WScript.Echo objExecObject.StdOut.ReadLine
Loop
End Sub
Thanks for your reply.
I tried your code but nothing is echo'd to stdout.
I think what is happening is that after the Exec method line executes, the
script "pauses" till its done, by that time, no stdout text is available
to
be captured.
Any suggestions?
Let's have a look at your current script, using a standard Windows tool that
generates an output, e.g. attrib.exe.
.
- Follow-Ups:
- Re: Capture text output of win app
- From: Tec92407
- Re: Capture text output of win app
- References:
- Capture text output of win app
- From: Tec92407
- Re: Capture text output of win app
- From: Pegasus \(MVP\)
- Re: Capture text output of win app
- From: Tec92407
- Capture text output of win app
- Prev by Date: Re: Capture text output of win app
- Next by Date: Re: vb script on vista X64 not working
- Previous by thread: Re: Capture text output of win app
- Next by thread: Re: Capture text output of win app
- Index(es):
Relevant Pages
|