Sign in to follow this  
CodeMachine

Capture Console Output

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this