Create a process and end the current process

S

stephenculver

I am trying to develop a tool to help update the application. To do so
I need to create a separate process to start an installer. I then need
to end the current process, since it will be overwritten by the
installation.

I have found all the articles on creating a process and have tried
using the coredll.dll and OpenNet options, but neither seems to be
working.

We I look at the processes it seems the main process (the caller) never
ends. My belief is that the process I created is somehow still tied to
the original process, but I really am unsure.

Does anyone know of a solution to this problem.
 
P

Paul G. Tobey [eMVP]

"Ending the process" is just exiting the program, right? Are you doing
that? No, a forked process has no ownership over the process that started
it.

Paul T.
 
R

Rayogen

I was able to solve this problem by generating a exit command for my
main application. This would do two things. First it would launch the
installer application, second it would exit. The installer application
would wait X seconds for the main app to exit before installing the
updates. After verifcation the install was successful, the installer
would start the main app again and then exit.

External processes don't have access to other ones, and it really isn't
a good idea to try and control other processes.

I hope this helps

Norm Rericha
Applied Data System.net
 
P

Paul G. Tobey [eMVP]

You might also try getting a process handle to the parent process and
waiting for it to exit with WaitForSingleObject(), to avoid somewhat
arbitrary time-based delays in the installer...

Paul T.
 
S

stephenculver

It's me, the original poster, I wasn't logged in earlier....


I have tried something similiar to what you are suggesting, but what
seems to be happening is strange.

I will run the code in the Main function of my app just after the main
form has closed. This code then calls the process. When I run it in
Debug mode of VS it works just fine, but when I run it normally, it
seems that the original process never ends. I have verified this by
using a third party process task manager tool and confirmed the old app
is still running.

Is there some particular way you have to exit the app to make it
function properly.
 
P

Paul G. Tobey [eMVP]

If it's not ending, there's a clear reason. The most likely ones that I can
think of are: 1) there's a thread running in the application which hasn't
exited, 2) the code does something which, in non-debug mode, keeps the main
function active forever. Without seeing the code itself, we aren't going to
be able to give any real answer...

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top