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

vb6 calling an exe with shell, how to get the results when exe don

2,795 views
Skip to first unread message

Bradley1234

unread,
Nov 26, 2007, 9:02:11 PM11/26/07
to
first I hope this is an okay question for this ng?

Im trying to call an exe using vb6 which I can do already, that part works.
but when the exe finishes I want to get the return values and use them in the
code to tell the user the action passed/failed or whatever.

I started by calling with shell command, tried several ways to catch the
results?

so the code just has a button and text box. button calls the exe, it seems
to always return 0, but when it fails its supposed to return 1 - 7 based on
the error. must not be doing the right thing

button click starts the exe, when I close the exe file and return to vb code
I want to catch the exit codes, how?

thanks in advance

Ralph

unread,
Nov 26, 2007, 9:55:09 PM11/26/07
to

Bradley1234

unread,
Nov 27, 2007, 2:46:01 PM11/27/07
to
Thanks Ralph thats very helpful, Ive checked all of those examples and tried
them.

What happens is that I just want to get the exit code when the called exe
terminates and either Im not doing this right or the app itself is not
returning the various exit codes

in my code,

GetExitCodeProcess proc.hProcess, RetVal2

RetVal2 is always -1 but then if I change it to

RetVal = GetExitCodeProcess (proc.hProcess, RetVal2)

and assume that proc.hProcess works fine, it starts and I can see the
process number in the task manager associated with my expected exe
application that Im starting up

then here RetVal is always = 0

In the various sample programs, they seem to all use similar if not
identical calls to kernel32 functions. So now Im left wondering if the
application doesnt actually return various exit codes, or Im not doing the
right thing to discover them. Contacting the person responsible for the app
itself, I get an out of office reply...
"Ralph" wrote:

> ....
>
> Another...
> http://www.vbaccelerator.com/home/vb/code/libraries/Shell_Projects/Shell_And_Wait_For_Completion/article.asp
>
>
>
>
>
>

Bradley1234

unread,
Nov 27, 2007, 4:18:01 PM11/27/07
to
Ok I figured it out, using one of the original main links I followed it out
and found it,

http://support.microsoft.com/kb/129796/EN-US/

quote...

Getting the Exit Code from the Shelled Application
It was common for a DOS application to return an exit code indicating the
status of the completed application. While Windows provides other ways to
convey the same information, some applications only provide exit codes.
Passing the process handle to the GetExitCodeProcess() API allows you to
retrieve this information.

I made a new app, copied and pasted the example, inserted my app for notepad
and it works perfect

Using this, it also shows that the app in question returns code 0 all the time

thanks

0 new messages