Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2005

Tip: Looking for answers? Try searching our database.

Lauching an App and using the Exit Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Micus - 23 Jun 2005 21:07 GMT
Greetings,

   I need to execute 2 applications from an application or batch file. The
first app launched has the user enter a product key and the app's exit code
will be 0 (failed) or 1 (succeeded). Based on the exit code of the first
app, the second app will be run.

   My problems :

       Using a batch file to launch the applications produces an
unattractive command prompt window in the background. I need this to look
pretty. The benefit of using a batch file is that logic based on the exit
code of the first app can be written (errorlevel variable).

       Using the system() method to launch the application produces the
command prompt window and does not return the exit code.

       Using ShellExecuteEx() does not return the exit code of the first
app.

  If anyone knows how to minimize the command prompt window from within a
batch file or how to obtain the exit code of an application launched from
within another application, it would be super. Any other suggestions are
welcome.

TIA,
M
Igor Tandetnik - 23 Jun 2005 21:10 GMT
>    I need to execute 2 applications from an application or batch
> file. The first app launched has the user enter a product key and the
[quoted text clipped - 3 lines]
>        Using ShellExecuteEx() does not return the exit code of the
> first app.

Use SEE_MASK_NOCLOSEPROCESS flag, and you will get an hProcess HANDLE to
the new process. Wait for the process to terminate with
WaitForSingleObject, then obtain its exit code with GetExitCodeProcess.
Don't forget to call CloseHandle on your handle.

Or you can use CreateProcess instead of ShellExecuteEx, then proceed as
above. Remember that in this case, you get back two handles (for the
process and for the main thread of that process), both of which you need
to close.
Signature

With best wishes,
   Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925

Micus - 23 Jun 2005 21:45 GMT
> >    I need to execute 2 applications from an application or batch
> > file. The first app launched has the user enter a product key and the
[quoted text clipped - 13 lines]
> process and for the main thread of that process), both of which you need
> to close.

Thanks Igor, I'll give it a shot,
M
Micus - 24 Jun 2005 09:45 GMT
> >    I need to execute 2 applications from an application or batch
> > file. The first app launched has the user enter a product key and the
[quoted text clipped - 13 lines]
> process and for the main thread of that process), both of which you need
> to close.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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



©2008 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.