What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Capture output of launched external application?

Capture output of launched external application?
Author: Message:
V@no
Full Member
***

Avatar
sexy

Posts: 162
Joined: Mar 2004
O.P. Capture output of launched external application?
Hello!
I'm trying launch an external program via MP!L script. So far I found only one way to do so:
code:
  var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute('C:\\myprogram.exe', '', '', "open", 0);

myprogram.exe returns some text which I need to capture. unfortunetly ShellExecute only returns error codes or such...
Is there a way launch an external application (with no window showed if possible) and capture the output?

Thank you.

P.S. I dont know advanced programming languages such as C or even VB...
12-03-2006 09:07 AM
Profile PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: Capture output of launched external application?
code:
var Shell = new ActiveXObject('WScript.Shell');
var oExec = Shell.Exec("C:\\myprogram.exe");
Debug.Trace(oExec.StdOut.ReadAll());
12-03-2006 09:13 AM
Profile PM Find Quote Report
V@no
Full Member
***

Avatar
sexy

Posts: 162
Joined: Mar 2004
O.P. RE: Capture output of launched external application?
Yes, that's it, very good.
Now, if I could get rid off the command prompt window it would be perfect!

Thanks
12-03-2006 09:59 AM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Capture output of launched external application?
quote:
Originally posted by V@no
Now, if I could get rid off the command prompt window it would be perfect!

I think it might be possible to iterate through open windows, get the handle to the command prompt and hide/close it
<Eljay> "Problems encountered: shit blew up" :zippy:
12-03-2006 01:59 PM
Profile PM Find Quote Report
V@no
Full Member
***

Avatar
sexy

Posts: 162
Joined: Mar 2004
O.P. RE: Capture output of launched external application?
yes, I've tryed that, but again, with "open" I can not capture the output...
12-04-2006 02:12 AM
Profile PM Find Quote Report
V@no
Full Member
***

Avatar
sexy

Posts: 162
Joined: Mar 2004
O.P. RE: Capture output of launched external application?
I found a work around this...I'm using "open" instead of "exec", that allowes to run hidden command prompt window.
then I created a myprogram.bat file where I set command line to execute my program and redirect output into a file:
code:
C:\myprogram.exe > C:\output.txt
and finaly I read the output file in the script.

Somebody might find this is useful, here is the script code:
code:
var outputfile = "C:\\output.txt";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var Shell = new ActiveXObject('WScript.Shell');
var oExec = Shell.Run("C:\\myprogram.bat", 0, true);
var output = "";
if(fso.FileExists(outputfile))
  output = fso.OpenTextFile(outputfile, 1, true, 0).fH.ReadAll();

12-05-2006 03:17 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On