• Advertisement
Sign in to follow this  

Capture Console Output

This topic is 4374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Im using VisualBasic6 and have the following to execute an external program and wait for it's execution: Dim wScr as Object Set wScr = CreateObject("WScript.Shell") Call wScr.Run("myprogram.exe", 1, true) "myprogram.exe" generates some output to a file, and also some error-messages in the console window (DOS). How do I capture this output? I want the program to be able to execute on Windows NT/2000/XP/2003. Is there a good idéa to use "WScript.Shell"? Or should I call the external program in another way or anything that maybe makes it safer to be able to execute on the above systems? Regards Andreas

Share this post


Link to post
Share on other sites
Advertisement
I do the same to run external console application and capture output to show it in log window(Code is in C# though)


wshShell = new WshShellClass();
oExec = wshShell.Exec( cmdStr );
string Str = null;

while ( oExec.Status == 0 ) {
try {
Str = oExec.StdOut.ReadLine();
// output Str string to wherever i'd like
}
catch {}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement