I am using MSVS 2008. I am writing an application in c, and would like to know what's the best way to restart an application in windows.
I looked around and someone was doing something like this, but I am not sure if that is the best way or if that even creates a whole new process.
if(command == restart)
{
printf("program exiting!\n");
Sleep(2000);
system("cls");
WinExec("my_app.exe", SW_SHOW);
exit(0);
}
Thanks
You'll have to have one process extra for this.
From your application, you'll launch that process. It will wait for your main application to exit, then wait for whatever that it should happen (update, ...) and then restart it killing itself.
Starting app from within itself won't be ok since you won't be able to update anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With