Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / November 2007



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bradley1234 - 27 Nov 2007 02:02 GMT
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 - 27 Nov 2007 02:55 GMT
> first I hope this is an okay question for this ng?
>
[quoted text clipped - 11 lines]
> button click starts the exe, when I close the exe file and return to vb code
> I want to catch the exit codes, how?

Google for "ShellExecute and Wait". There are a couple of zillion ways.

Here is the granddaddy version ...
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvb4/html/ms
dn_shelexec.asp


Another...
http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1102&lngWId=-10

More...
http://vbcity.com/forums/topic.asp?tid=22303

...

Another...
http://www.vbaccelerator.com/home/vb/code/libraries/Shell_Projects/Shell_And_Wai
t_For_Completion/article.asp

Bradley1234 - 27 Nov 2007 19:46 GMT
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...

> > first I hope this is an okay question for this ng?
> >
[quoted text clipped - 32 lines]
> Another...
> http://www.vbaccelerator.com/home/vb/code/libraries/Shell_Projects/Shell_And_Wai
t_For_Completion/article.asp
Bradley1234 - 27 Nov 2007 21:18 GMT
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

> Thanks Ralph  thats very helpful, Ive checked all of those examples and tried
> them.
[quoted text clipped - 59 lines]
> > Another...
> > http://www.vbaccelerator.com/home/vb/code/libraries/Shell_Projects/Shell_And_Wai
t_For_Completion/article.asp
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.