473,698 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wait for a program and the program it started (launcher app) to exit in C#

14 New Member
I ran an outside program that launched another program. I created a process for the launcher program and waited for that to exit, but what I need is to have it wait for the 2nd program to exit.

system.diagnost ics.process instApp = system.diagnost ics.process.sta rt("Setup.exe") ;
instApp.WaitFor Exit();

//code that is dependent upon the installation of the above program

Problem I'm having is that the Setup.exe extracts a few files for the installation process, then launches the actual installer. Once the actual installer is ran, my 'WaitForExit()' thinks it's over. Is there a way to wait for the Setup.exe and any program it launches to exit before executing the next line(s) of code?

Thank you in advance.
Jim
Mar 30 '08 #1
8 2064
balabaster
797 Recognized Expert Contributor
So let me understand this correctly...

Your app fires off the some kind of extractor for your installer...the installer then runs but by which time your extractor has finished and triggered your app to continue on before the installer has completed. Consequently the installer process that your application relies on having completed fails?
Mar 30 '08 #2
TxAg03
14 New Member
Thank you for your quick response balabaster.

Exactly!!! But how can I test to make sure that the installer and whatever program(s) it launches have finished before continuing in my code? I've been looking into Threads, but not quite sure if that's the correct path to go.

Any suggestions?
Mar 30 '08 #3
balabaster
797 Recognized Expert Contributor
Thank you for your quick response balabaster.

Exactly!!! But how can I test to make sure that the installer and whatever program(s) it launches have finished before continuing in my code? I've been looking into Threads, but not quite sure if that's the correct path to go.

Any suggestions?
I'm guessing what you would need to do is look into processes. In your setup launcher application, have it extract the files and then run the installer. Use the System.Diagnost ics.Process namespace to figure out the process id of the installer and force your setup launcher to remain active until the process with the id of the installer closes. At that point your setup launcher can exit. In your main application you can use your regular WaitForExit() method to wait for your setup launcher to exit.
Mar 30 '08 #4
TxAg03
14 New Member
I was able to determine the process ID of the launcher program, but am having trouble determining the process ID of the installer it opens. Is there something that can quickly and easily determine if a program starts another program and wait for that 2nd program to finish?
Mar 31 '08 #5
balabaster
797 Recognized Expert Contributor
I was able to determine the process ID of the launcher program, but am having trouble determining the process ID of the installer it opens. Is there something that can quickly and easily determine if a program starts another program and wait for that 2nd program to finish?
Not as far as I'm aware...but I'm sure someone can come up with some ingenious workaround that would give you what you're looking for.
Mar 31 '08 #6
TxAg03
14 New Member
For those that are interested in the answer, the best solution I was able to find was to get the main program ID and the program ID of the program it launches. Wait for the main program to finish, then wait for the launched program to finish.
Jul 10 '08 #7
Plater
7,872 Recognized Expert Expert
For those that are interested in the answer, the best solution I was able to find was to get the main program ID and the program ID of the program it launches. Wait for the main program to finish, then wait for the launched program to finish.
Isn't that what was suggested earlier? How did you end up finding the ID of the 2nd process?
I'm not sure .NET gives you the ability, but there should have been a parent/child relationship between those two objects. Win32API at very least could be used to find that relationship?
Jul 10 '08 #8
TxAg03
14 New Member
I'm sure there is a much better way to do so, like you mentioned. Being pressed for time, I ran the main exe and in the windows task manager processes, I waited to see what the launcher exe name was. I tried finding a way to get the child ID, but wasn't able to find it.
Jul 10 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2551
by: Terry Brown | last post by:
I am trying to use WaitForExit to determine when an external application I have launched has exited (duh!). I found examples everywhere and it seemed simple and this works perfectly: Dim myProcess As Process = _ System.Diagnostics.Process.Start("notepad.exe") ' wait until it exits myProcess.WaitForExit()
4
2809
by: Terry Olsen | last post by:
I have loop that calls a Sub that runs the following code: Dim WinZip As System.Diagnostics.Process Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName & ".zip @""" & appPth & "WksBkup.txt""" WinZip.Start("c:\Program Files\WinZip\wzzip.exe", args) WinZip.WaitForExit() Do If WinZip.HasExited = True Then Exit Do Loop
4
1397
by: Tom van Stiphout | last post by:
I have a "Launcher" application that does version checking. It will copy a newer version from the server if needed, and then start the main application. I believe Tony Toews "Auto FE Updater" serves a similar purpose. My app calls ShellExecute to run the command line specified in a "Launcher.ini" file. A typical command line may be: AppCommandLine="C:\Program Files\Microsoft Office2003\OFFICE11\MSACCESS.EXE" C:\Test\Test.mde This all...
19
11486
by: ern | last post by:
Right now I'm using exit(0) to terminate my program. My program is a console .exe application. After the "exit(0)" line of code is encountered, the console application waits for an enter press, before terminating. I want it to terminate completely without having to press enter manually. Anybody know what I might be missing here ?
12
5266
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock block protecting a resource. Thread 2 and 3 also have a SyncLock block protecting the same resource and after executing some code in their blocks they both do a Monitor.Pulse to hand of the locked resource back to thread 1. While thread 1 has...
16
2969
by: RichardP | last post by:
Hi there everyone - I'm new to this forum. I am having an issue when running an application from an instance of Access which has been started through automation (early or late bound, makes no difference). No warning / confirmation messages are issued (eg. when running action queries, deleting records from a datasheet, deleting database objects such as tables).
1
5681
by: peterggmss | last post by:
This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for frmRandom, i tried it with the Sleep API and a Do/Until Loop and neither worked, could you please help me, I have my code below. frmMachine 'Slot Machine, (c) 2006 Peter Browne, GPL Licensed ' 'Peter Browne 'Sheridan Corporate Centre '2155 Leanne...
5
25226
by: chenthil | last post by:
In my Java program I need to call two DOS batch programs namely call.bat and start.bat. First I need to start the batch program call.bat and once that program is completed, I need to call the other batch file start.bat. The piece of code which I am using is: public static void ExecuteScripts(){ try { \\Start the first batch program call.bat Process p = Runtime.getRuntime().exec("cmd /c start .\\scripts\\call.bat"); ...
22
11747
by: Jason Zheng | last post by:
This may be a silly question but is possible for os.wait() to lose track of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20 (i686), gcc4.1.1, and glibc-2.5. Here's what happened in my situation. I first created a few child processes with Popen, then in a while(True) loop wait on any of the child process to exit, then restart a child process: import os from subprocess import Popen
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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
9170
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
9031
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
8873
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
4372
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
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.