1

I'm sorry if this question exists, I can't specifically find this case when googling it up, and to be frank I'm even unsure what tags to use.

I am developping a solution, with a launcher. There is a problem however: my team doesn't want to make the launcher and the actual program two different binary files, which I believe is a conception mistake.

Either way they won't change their mind so we're going with that.

My "launcher" part of the program currently succesfully fetches new versions on our server. I however want to be able to, as soon as the new version is downloaded, quit the current binary, delete the old one, launch the new one.

It has, ontop of that, to be multiplatform.

Now, if I recall correctly I think that on linux, it's very possible to delete a binary on the hard drive as it runs in memory. I'm really, really unsure if it can be done on Windows however.

Is it possible to delete a program that is currently running on windows, with an instruction to launch the new one somehow?

Tell me what you think. In my mind it really sounds unfeasable, but if it can be done, I would really like to know how. At the very least, if it can't be done on either OS, I'll just show my team the answers.

Thank you in advance, sorry about the very vague "what if" questions and such.

Tohkai
  • 93
  • 1
  • 9
  • 1
    I think it is possible on windows as many softwares out there have updaters which will close and reopen binary files. The one on the top of my head right now is [DS4windows](https://github.com/Jays2Kings/DS4Windows), I would recommend checking it out and seeing if it has code you might be able to build off of. Other then that, sorry I can't be to much of a help. – Hojo.Timberwolf Dec 18 '17 at 04:43
  • It's already something, thanks. I'll keep looking. – Tohkai Dec 18 '17 at 04:45

1 Answers1

1

I agree with you, it's probably not a good idea. The question was raised before.

How can a C++ binary replace itself?

The answers includes a description how to do this on Windows, where the use of "shim" allows you to do what you described with a launcher, without actually having to develop this launcher yourself.

Johan Witters
  • 1,529
  • 11
  • 23