Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling an executable that runs on the command line and fetching return values

1 view
Skip to first unread message

Water Cooler v2

unread,
Jan 11, 2008, 8:26:13 AM1/11/08
to
I've done a lot of API stuff in my time, real hardcore but am a bit
out of touch now.

From within my VB.NET WinForms app, I want to call an external
executable. The said executable runs on a command line and takes two
params.

Calling the executable is no biggie. I could use the old VB 6 shell,
or the Win32 API ShellExecuteEx or CreateProcess to fork a new
process. The problem is getting the status of the process and its
return values of success of failure.

Can you please help?

Christian ASTOR

unread,
Jan 11, 2008, 9:30:02 AM1/11/08
to
On 11 jan, 14:26, Water Cooler v2 <wtr_...@yahoo.com> wrote:

> Calling the executable is no biggie. I could use the old VB 6 shell,
> or the Win32 API ShellExecuteEx or CreateProcess to fork a new
> process. The problem is getting the status of the process and its
> return values of success of failure.
>
> Can you please help?

WaitForSingleObject()
GetExitCodeProcess()

Sam of California

unread,
Jan 11, 2008, 12:24:20 PM1/11/08
to
So you need a refresher on the use of documentation.

Start with the CreateProcess documentation; such as:
http://msdn2.microsoft.com/en-us/library/ms682425.aspx

Then near the bottom is the "See Also". See GetExitCodeProcess in that list.


"Water Cooler v2" <wtr...@yahoo.com> wrote in message
news:4d2f0d8b-a4cc-4d6b...@e4g2000hsg.googlegroups.com...

Water Cooler v2

unread,
Jan 16, 2008, 9:13:09 AM1/16/08
to
On Jan 11, 5:24 pm, "Sam of California"

<sam...@social.rr.com_change_social_to_socal> wrote:
> So you need a refresher on the use of documentation.
>
> Start with the CreateProcess documentation; such as:http://msdn2.microsoft.com/en-us/library/ms682425.aspx
>
> Then near the bottom is the "See Also". See GetExitCodeProcess in that list.
>
> "Water Cooler v2" <wtr_...@yahoo.com> wrote in messagenews:4d2f0d8b-a4cc-4d6b...@e4g2000hsg.googlegroups.com...

>
> > I've done a lot of API stuff in my time, real hardcore but am a bit
> > out of touch now.
>
> > From within my VB.NET WinForms app, I want to call an external
> > executable. The said executable runs on a command line and takes two
> > params.
>
> > Calling the executable is no biggie. I could use the old VB 6 shell,
> > or the Win32 API ShellExecuteEx or CreateProcess to fork a new
> > process. The problem is getting the status of the process and its
> > return values of success of failure.
>
> > Can you please help?

Thanks very much, Chris and Sam.

Although GetExitCodeProcess will be useful to recieve the exit code,
which is an integer/long, I will also need to retrieve the 'string'
messages that are returned by the console application.

Is there an API or a set of API's to do that?

Bob Masta

unread,
Jan 17, 2008, 8:02:48 AM1/17/08
to

One crude but effective approach would be to redirect the console
output to a file that your program could then read.

Best regards,


Bob Masta

DAQARTA v3.50
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, FREE Signal Generator
Science with your sound card!

Sam of California

unread,
Jan 17, 2008, 10:04:28 PM1/17/08
to
"Water Cooler v2" <wtr...@yahoo.com> wrote in message
news:415f33eb-fa60-4496...@k39g2000hsf.googlegroups.com...

>
> Although GetExitCodeProcess will be useful to recieve the exit code,
> which is an integer/long, I will also need to retrieve the 'string'
> messages that are returned by the console application.
>
> Is there an API or a set of API's to do that?

I am not sure what you mean by "return". Do you mean that you need to read
the text written to the console, or something else? If you need to get the
text written to the console, and if I understand what else you are asking,
then the typical solution is to redirect the executed program's standard
output so the executing program can see what the executed program says. That
will work only if the executed program writes to standard output. If it does
not write to standard output then redirecting the output to a file won't
work either.

Water Cooler v2

unread,
Jan 18, 2008, 12:12:22 PM1/18/08
to
On Jan 18, 3:04 am, "Sam of California"
<sam...@social.rr.com_change_social_to_socal> wrote:
> "Water Cooler v2" <wtr_...@yahoo.com> wrote in messagenews:415f33eb-fa60-4496...@k39g2000hsf.googlegroups.com...

Thank you, Sam.

I wrote to Jeff Richter and he replied with the same answer that I
redirect the standard output and standard error for that process to my
calling process. Thanks. I think I can do that.

0 new messages