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?
> 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()
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...
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?
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!
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.
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.