472,351 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

Lauching an App and using the Exit Code

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
Nov 17 '05 #1
3 1611
"Micus" <No**@nowhere.com> wrote in message
news:u$**************@TK2MSFTNGP15.phx.gbl
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.

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.
--
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
Nov 17 '05 #2

"Igor Tandetnik" <it********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
"Micus" <No**@nowhere.com> wrote in message
news:u$**************@TK2MSFTNGP15.phx.gbl
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.

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


Thanks Igor, I'll give it a shot,
M
Nov 17 '05 #3

"Igor Tandetnik" <it********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
"Micus" <No**@nowhere.com> wrote in message
news:u$**************@TK2MSFTNGP15.phx.gbl
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.

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

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Thang Nguyen | last post by:
Hi, my page contains an applet. When I click on a link on the page, the applet will be launched.Now I need my page can be automatically closed...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on...
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for...
3
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The...
4
by: c_shah | last post by:
Windows form application I have an accounting application, the main form of that application can be launched from other application passing the...
11
by: intheend | last post by:
respected i have launch a application using the php . like nmapfe or ethreal but the basic functions like system and exec is not workiking ... the...
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2, for windows application. How can U stop the DOS windows creation when I redirect the stderr output from the C-code...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.