Monitor a process when it stops

Joined
Mar 13, 2007
Messages
5
Programming Experience
Beginner
I have a situation where I'm running a silent install of an application called Interplot written by Bentley Corp. When the setup.exe /s is started it inturns starts another process. If I use the command
Dim myProcess_Install As Process = System.Diagnostics.Process.Start("C:\Temp\Interplot_08_05_02_63\Install\setup.exe", "/s") it only monitors the setup.exe until it passes off to the second process. The Process name is _INS5576._MP. I'm trying to find the second process that's already running and wait for it to exit. Here is my code:

Module Process_Running
Sub ActivatePrevInstance(ByVal argStrAppToFind AsString)
Dim MyProcess As Process
Dim objProcess AsNew Process()
Dim objProcesses() As Process
objProcesses = Process.GetProcesses()
ForEach objProcess In objProcesses
If (objProcess.ProcessName) = (argStrAppToFind) Then
MyProcess = Process.GetCurrentProcess
ExitFor
EndIf
Next
If MyProcess.Responding Then
MyProcess.WaitForExit()
EndIf

EndSub
EndModule

The variable argStrAppToFind is being passed _INS5576._MP. everything runs untill it gets to the line MyProcess.WaitForExit(). At that point it just hangs. When in debug mode and you are looking at the "Locals" it say that is can't find any information on the process. Any help would be greatly appreciated.

Thanks
-Phillip
 
MyProcess=Process.GetCurrentProcess and MyProcess.WaitForExit() makes current process wait for itself to exit. Since you perhaps found objProcess you could better wait for this?

Also you could instead from current process first start process1 and when that is finished start process2 ?
 
I've tried to wait for objProject, but all I can get is the name. When I try and setup the waitforexit it says that the string processname is not a process. That is one of the problems I'm having. I can't figure out how to capture the process when it finds the processname.

On the second part of your reply, the second process starts automaticlly. I don't no how to monitor for a process that starts automaticlly.

Thanks for your help I really apreciate it.
 
objProcess is not a string, its an instance of a Process you got from Process.GetProcesses()
 
Back
Top