Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 4.8.4 way to change the running excusable name in runtime
Forum Updated to NodeBB v4.3 + New Features

Qt 4.8.4 way to change the running excusable name in runtime

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    Hey
    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      On windows you can't change/modify/etc... a running application.

      One way to do that is to have an application launcher, the launcher checks if a new version is available, downloads it, performs whatever is needed and then starts the application.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        the main exe is the application launcher , is there any other method to start the app exe ? not using cmd or script

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          AFAIK no, but you can write your own launcher executable that does that: check if there is something and if there is not, start your application. That's what firefox does for example.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • U Offline
            U Offline
            umen242
            wrote on last edited by
            #5

            so i will hold 2 excusable , and the launcher will be my main exe
            when starting it will check if there is update ,
            if yes download and rename
            if no start the main app
            right ?
            is there any other way ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Right.
              Like I said before you can't modify the file of a running application on windows.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • U Offline
                U Offline
                umen242
                wrote on last edited by
                #7

                looks like it can ( didnit try it )
                "Your text to link here...":http://stackoverflow.com/questions/9162969/how-can-a-c-binary-replace-itself

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Then you can try using QFile::rename

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    MuldeR
                    wrote on last edited by
                    #9

                    [quote author="umen242" date="1376053506"]Hey
                    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 [/quote]

                    Typically you could go like this:

                    1. Have the "main" EXE check for updates

                    2. If update is available, download "updater.exe" to the system TEMP folder

                    3. Let the "main" EXE start the "updater.exe" it just downloaded (from TEMP folder) and make the "main" EXE terminate itself right after that

                    4. Now the "updater.exe" can install the update and also replace the "main" EXE with a new version - because "main" EXE is not running anymore

                    I'd recommend to create "updater.exe" with "NSIS":http://nsis.sourceforge.net/Main_Page

                    --

                    How does "updater.exe" know where "main" EXE is located?

                    Just have the "main" EXE pass its own path to the "update.exe" via command-line parameter.

                    --

                    How to clean up the "updater.exe" from TEMP folder?

                    Obviously the "updater.exe" can not delete itself. But there is a function in the Win32 API which allows files to be scheduled for deletion on next reboot.

                    "MoveFileEx":http://tinyurl.com/movefilex

                    (See MOVEFILE_DELAY_UNTIL_REBOOT flag for details)

                    My OpenSource software at: http://muldersoft.com/

                    Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                    Go visit the coop: http://youtu.be/Jay...

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Interesting alternative ! Thanks

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved