0

i have Qt c++ app that on each start is checking if there is new executable update file and if there is it downloading it, the problem is how can i change the name of the old executble to for example : foo_tmp.exe and the new executable to : foo.exe or in runtime or on closing or on start something

user63898
  • 29,839
  • 85
  • 272
  • 514

1 Answers1

1

QFile::rename is a static method that will allow you to rename a file.

However renaming the currently running executable file will cause you issues. As the file is in use by the operating system you will either be prevented from doing this, cause undefined behaviour or it will simply not work. You should most likely have a launcher application that checks for updates to the main application before starting it.

dunc123
  • 2,595
  • 1
  • 11
  • 11
  • 1
    - because Windows at least prevents deleting a running executable but allows renaming – Alex K. Aug 09 '13 at 13:11
  • Good point, I didn't realise the poster wanted to rename the running executable. I'll update my answer. – dunc123 Aug 09 '13 at 13:14
  • ok what is launcher application ? i use the main exe file as the starting point of the app . i dont what to start the exe with cmd or any other app/script – user63898 Aug 09 '13 at 14:00