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. exe file replace using QProcess
Forum Updated to NodeBB v4.3 + New Features

exe file replace using QProcess

Scheduled Pinned Locked Moved Solved General and Desktop
29 Posts 5 Posters 9.2k Views 4 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.
  • mrjjM mrjj

    @4j1th
    Hmm. i think might need to run cmd also as del is part of command.exe.
    http://stackoverflow.com/questions/21596104/how-to-execute-a-cmd-command-using-qprocess
    he uses "cmd"
    something like
    process->start("cmd", QStringList() << "del " << currentpath);
    maybe ?

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by
    #10

    @4j1th said:

    I am trying to update my soft. itself in windows, I can't replace a running exe itself with in so I try to do it by using QProcess.

    You can't, the OS will lock the file and will not allow you to modify it. It doesn't matter if you use QProcess or cmd, or explorer, it will not work.

    Read and abide by the Qt Code of Conduct

    4 1 Reply Last reply
    1
    • mrjjM mrjj

      @4j1th
      Hmm. i think might need to run cmd also as del is part of command.exe.
      http://stackoverflow.com/questions/21596104/how-to-execute-a-cmd-command-using-qprocess
      he uses "cmd"
      something like
      process->start("cmd", QStringList() << "del " << currentpath);
      maybe ?

      4 Offline
      4 Offline
      4j1th
      wrote on last edited by
      #11

      @mrjj no luck it can't delete any file

      Pardon my English
      Thank you.

      1 Reply Last reply
      0
      • kshegunovK kshegunov

        @4j1th said:

        I am trying to update my soft. itself in windows, I can't replace a running exe itself with in so I try to do it by using QProcess.

        You can't, the OS will lock the file and will not allow you to modify it. It doesn't matter if you use QProcess or cmd, or explorer, it will not work.

        4 Offline
        4 Offline
        4j1th
        wrote on last edited by 4j1th
        #12

        @kshegunov so you're suggesting me to write another programme to run update

        But this idea works on linux.

        Pardon my English
        Thank you.

        mrjjM 1 Reply Last reply
        0
        • 4 4j1th

          @kshegunov so you're suggesting me to write another programme to run update

          But this idea works on linux.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #13

          @4j1th
          Hi
          just tested in win 7.
          it wont allow to delete running exe.

          Linux will, i know. but Windows wont allow.

          4 1 Reply Last reply
          0
          • mrjjM mrjj

            @4j1th
            Hi
            just tested in win 7.
            it wont allow to delete running exe.

            Linux will, i know. but Windows wont allow.

            4 Offline
            4 Offline
            4j1th
            wrote on last edited by
            #14

            @mrjj can you delete any other file, I can't do it either

            Pardon my English
            Thank you.

            mrjjM 1 Reply Last reply
            1
            • 4 4j1th

              @mrjj can you delete any other file, I can't do it either

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #15

              @4j1th
              hi

               QProcess process;
                  process.start("cmd", QStringList() <<"/C" << "del" << "e:/test.txt " );
              

              this delete the file i put on e:\

              4 1 Reply Last reply
              1
              • mrjjM mrjj

                @4j1th
                hi

                 QProcess process;
                    process.start("cmd", QStringList() <<"/C" << "del" << "e:/test.txt " );
                

                this delete the file i put on e:\

                4 Offline
                4 Offline
                4j1th
                wrote on last edited by
                #16

                @mrjj @kshegunov

                you're right, can't replace running exe, so I think the best way to update is write an another app for updation right?

                Pardon my English
                Thank you.

                mrjjM 1 Reply Last reply
                1
                • 4 4j1th

                  @mrjj @kshegunov

                  you're right, can't replace running exe, so I think the best way to update is write an another app for updation right?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #17

                  @4j1th
                  Well even another program cannot override the exe, so the updater must
                  close the running version.

                  4 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @4j1th
                    Well even another program cannot override the exe, so the updater must
                    close the running version.

                    4 Offline
                    4 Offline
                    4j1th
                    wrote on last edited by
                    #18

                    @mrjj Thank you for your help, this is the second time you help me like a guru

                    Thank you

                    Pardon my English
                    Thank you.

                    mrjjM 1 Reply Last reply
                    0
                    • 4 4j1th

                      @mrjj Thank you for your help, this is the second time you help me like a guru

                      Thank you

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #19

                      @4j1th
                      You are most welcome :)
                      The exe you are trying to update. is it your own program?

                      4 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @4j1th
                        You are most welcome :)
                        The exe you are trying to update. is it your own program?

                        4 Offline
                        4 Offline
                        4j1th
                        wrote on last edited by
                        #20

                        @mrjj yes

                        Pardon my English
                        Thank you.

                        mrjjM 1 Reply Last reply
                        0
                        • 4 4j1th

                          @mrjj yes

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #21

                          @4j1th
                          Ok. that makes it easier to get it to close. :)
                          Will user check for update from inside the program or how will that happen?
                          (if i may ask)

                          4 2 Replies Last reply
                          0
                          • mrjjM mrjj

                            @4j1th
                            Ok. that makes it easier to get it to close. :)
                            Will user check for update from inside the program or how will that happen?
                            (if i may ask)

                            4 Offline
                            4 Offline
                            4j1th
                            wrote on last edited by 4j1th
                            #22

                            @mrjj When the app starts it checks for update if available-> ask for update permission(user) -> invoke the updater using QProcess -> as you said close the app -> download and replace the exe

                            Pardon my English
                            Thank you.

                            1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @4j1th
                              Ok. that makes it easier to get it to close. :)
                              Will user check for update from inside the program or how will that happen?
                              (if i may ask)

                              4 Offline
                              4 Offline
                              4j1th
                              wrote on last edited by
                              #23

                              @mrjj Qt installer framework can replace a running exe and dll I don't know how!

                              Pardon my English
                              Thank you.

                              mrjjM 1 Reply Last reply
                              0
                              • 4 4j1th

                                @mrjj Qt installer framework can replace a running exe and dll I don't know how!

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #24

                                @4j1th said:
                                well on windows its not so hard using windows API.

                                1 Reply Last reply
                                0
                                • R Offline
                                  R Offline
                                  Rondog
                                  wrote on last edited by
                                  #25

                                  There is a link to an article that talks about this problem and possible solutions. http://www.catch22.net/tuts/self-deleting-executables on Windows.

                                  I, personally, would try to keep this sane. A separate updating utility that closes the original program and replaces or removes whatever should be replaced or removed is probably the safest thing to do.

                                  kshegunovK 1 Reply Last reply
                                  1
                                  • R Rondog

                                    There is a link to an article that talks about this problem and possible solutions. http://www.catch22.net/tuts/self-deleting-executables on Windows.

                                    I, personally, would try to keep this sane. A separate updating utility that closes the original program and replaces or removes whatever should be replaced or removed is probably the safest thing to do.

                                    kshegunovK Offline
                                    kshegunovK Offline
                                    kshegunov
                                    Moderators
                                    wrote on last edited by
                                    #26

                                    @Rondog

                                    I, personally, would try to keep this sane. A separate updating utility that closes the original program and replaces or removes whatever should be replaced or removed is probably the safest thing to do.

                                    I completely agree!

                                    Read and abide by the Qt Code of Conduct

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

                                      Hi,

                                      One possibility would be to use the Qt Installer Framework that, AFAIK, has an updating functionality

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

                                      4 1 Reply Last reply
                                      0
                                      • mrjjM Offline
                                        mrjjM Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #28

                                        ;)
                                        Do not worry
                                        he is not planning on overwriting the exe from WITHIN the exe :)
                                        Even @Rondogs link is pretty interesting,
                                        it does indeed smell of a complex way of shooting your foot off :)

                                        1 Reply Last reply
                                        0
                                        • SGaistS SGaist

                                          Hi,

                                          One possibility would be to use the Qt Installer Framework that, AFAIK, has an updating functionality

                                          4 Offline
                                          4 Offline
                                          4j1th
                                          wrote on last edited by 4j1th
                                          #29

                                          @SGaist
                                          tried qt installer framework but I don't think it can help the auto updating, launch a topic on this please see this link

                                          https://forum.qt.io/topic/61811/qt-installer-framework-auto-update

                                          Pardon my English
                                          Thank you.

                                          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