Re: Capture text output of win app

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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.


.



Relevant Pages

  • Strange file opening problem on WinNT
    ... a perl script on Windows NT that I've written (and ... The script uses the ... The strange thing about running it in Windows is that it ... ALSO "executes" the file it reads: in the same sense as if I double ...
    (comp.lang.perl.misc)
  • Re: Code run from IDLE but not via double-clicking on its *.py
    ... > started from inside of IDLE then it executes as it ... OS: Windows; Python 2.3.4. ... The shell windows opens to run the script in is ...
    (comp.lang.python)
  • slow script to watch
    ... I have a batch command "script" that was written for windows nt. ... using the echo command and then changes directories and executes ...
    (microsoft.public.windows.server.scripting)
  • Re: Capture text output of win app
    ... I used the following code to try to capture the output but "strOutput" is ... Set objshell = wscript.createobject ... I've tried both stdout and stderr but neither work. ... I think what is happening is that after the Exec method line executes, ...
    (microsoft.public.scripting.vbscript)
  • Re: Problem with multithreaded C# app on Windows CE
    ... Unlike the .NET Compact Framework ... Framework 2.0 provides Control.BeginInvoke that asynchronously executes ... supported and I don't see any problems with them, but BeginInvoke isn't. ... "Safe, Simple Multithreading in Windows Forms, Part 3", January ...
    (microsoft.public.dotnet.framework.compactframework)