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. Restart Application with Updated Executable.
Forum Updated to NodeBB v4.3 + New Features

Restart Application with Updated Executable.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 378 Views 2 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.
  • S Offline
    S Offline
    saee
    wrote on 16 Apr 2021, 13:21 last edited by saee
    #1

    Hi,
    I am new to Qt. I wrote a small application that should update itself with the click of the restart button.
    For that, I am applying the below logic :

    QDir sourceDir("/Desktop/FileTransferDemo");
    QDir currentDir(QDir::currentPath());
    QProcess copying;
    QStringList arg;
    arg.append(sourceDir.filePath("CopyAndRestore_v2"));
    arg.append(currentDir.path());
    copying.start("cp",arg);
    if (copying.waitForFinished(12000) == true)
    {
    if (copying.exitCode() == 0)
    {
    }
    }
    QFile app(currentDir.filePath("CopyAndRestore"));
    app.remove();
    QFile newApp(currentDir.filePath("CopyAndRestore_v2"));
    newApp.rename("CopyAndRestore");

    i.e . copying new exe at the same path remove old exe and rename the new.
    here CopyAndRestore is my old exe and CopyAndRestore_v2 is the new one.
    After renaming the new exe and on click of restart button with below code:

    on_pushButton_2_clicked()
    {
    QProcess::startDetached(QCoreApplication::applicationFilePath());
    qApp->quit();
    }

    I am expecting the application should restart with new version. Bt it is not restarting.
    is this approach correct? Please suggest the solution for the expected output.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Apr 2021, 18:26 last edited by
      #2

      Hi and welcome to devnet,

      Manipulating running executable is not something that is that easy especially on Windows. You might want to consider something like the Qt Installer Framework to manage that part.

      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
      2
      • S Offline
        S Offline
        saee
        wrote on 19 Apr 2021, 04:49 last edited by saee
        #3

        Hi thanks for replying. I am working on linux.
        I gone through the framework installer and got idea that it is creating installer for application.
        But in my case I expect my application itself should install the new version(software update). I am not getting how to proceed on that .
        If possible will you please elaborate how can I use mentioned solution in my case?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 Apr 2021, 18:06 last edited by
          #4

          Did you check that everything is properly in place ?
          That you pass a valid path to startDetached ?

          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

          1/4

          16 Apr 2021, 13:21

          • Login

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