473,699 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1681
"Micus" <No**@nowhere.c om> wrote in message
news:u$******** ******@TK2MSFTN GP15.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_NOCLOS EPROCESS flag, and you will get an hProcess HANDLE to
the new process. Wait for the process to terminate with
WaitForSingleOb ject, then obtain its exit code with GetExitCodeProc ess.
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********@mvp s.org> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
"Micus" <No**@nowhere.c om> wrote in message
news:u$******** ******@TK2MSFTN GP15.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_NOCLOS EPROCESS flag, and you will get an hProcess HANDLE to
the new process. Wait for the process to terminate with
WaitForSingleOb ject, then obtain its exit code with GetExitCodeProc ess.
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********@mvp s.org> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
"Micus" <No**@nowhere.c om> wrote in message
news:u$******** ******@TK2MSFTN GP15.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_NOCLOS EPROCESS flag, and you will get an hProcess HANDLE to
the new process. Wait for the process to terminate with
WaitForSingleOb ject, then obtain its exit code with GetExitCodeProc ess.
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
7639
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 applet to do this, but the poor thing is each time the script is called, IE will prompt to ask "the page you are viewing try to close the window ..". Is there any possible way for the browser not to prompt like that. I only know that a closing a...
11
6593
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
1
4009
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 live databases on the network. Is there a way, via code, when I get back in-house from being on the road to click a button, and select the backends I want to link to? I would want to delete all the current links and link to the "live"
2
5042
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 folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
3
5333
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 at it and let me know what I need to change. I have tried changing the "hwnd" type into intptr's but there seem to be other problems too, like it won't allow "lParam As Any" to be declared.
6
17195
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, process and output to the screen in my application when a message arrived. But the problem is how do I read the SMS message immediately when it arrived without my handphone BeEPINg for new message ? I read up the AT commands, but when getting down...
4
1090
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 standalone application. If it is started as a standalone application It shoud prompt a dialog box asking for account number. if the account number is valid it will launch a main form passing the account number
11
2020
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 lauch these kind of console application using hyperlinks or buttons ... other etst return system commands work like ls ... but console is not opening
4
2050
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# program? I've tried setting the process CreateNoWindow to true and set ProcessWindowStyle.Hidden but it's creating that black dos window in a flash and then close it. Thank you. -- Thanks.
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.