473,748 Members | 2,471 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 2066
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
2554
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
2813
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
11496
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
5270
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
2978
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
5686
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
25230
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
11751
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
8984
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
8823
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
9530
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...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
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
4593
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
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.