Is it possible to restart a program from inside a program?

Julen Uranga picture Julen Uranga · Oct 13, 2016 · Viewed 50.2k times · Source

I am developing a C++ program and it would be useful to use some function, script or something that makes the program restart. It's a big program so restarting all the variables manually will take me long time...

I do not know if there is any way to achieve this or if it is possible.

Answer

SingerOfTheFall picture SingerOfTheFall · Oct 13, 2016

If you really need to restart the whole program (i.e. to "close" and "open" again), the "proper" way would be to have a separate program with the sole purpose of restarting your main one. AFAIK a lot of applications with auto-update feature work this way. So when you need to restart your main program, you simply call the "restarter" one, and exit.