473,390 Members | 1,153 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 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 1666
"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 when I close my applet.I can call the script from my...
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 DTS package. If I PC Anywhere into the server on...
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 my hard drive and link to them rather than the...
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 Folders that don't follow our company's specified...
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 will work using vb .NET. Can anyone have a look...
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 application(VB.NET) will receive the SMS automatically,...
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 account number or it can be started as a...
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 safe mode is also off .. please tell me the way to...
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 application that I launch running from my C#...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.