Hello,

I am a Qt Developer with no knowledge on Windows specific development what so ever. Qt is great to allow developers like myself (more from the *nix world) to develop on Windows platforms as well with the same codebase.

All is well with InstallBuilder when it comes to bundling and customizing my installer but the main feature I was looking for is the possibility to autoupdate my application.

On the Install Builder documentation there is a chapter about that specific subject and a suggestion on how to automate the update checking process using the autoupdate executable generated from a XML on unattended mode.

For that to work, you need to spawn the process from your application to avoid having the user to interact with that application by himself. The idea is great, but I am having quite a few problems accomplishing that in Windows.

The Qt way to spawn a new process is using QProcess. The problem I am encountering is that QProcess does not solve problems with Windows Vista/7 UAC "feature". Whenever the underlying implementation calls CreateProcess, UAC denies it and we are left with no autoupdate.

Back to the Install Builder documentation, we see something around these lines:

    if (system("path/to/autoupdater --mode unattended") == 0){
 printf("Update available. Run autoupdate to apply it.");
}

But that does not look like a code that can be used. Can you guys provide us with a real example on how to:

  1. Check if there is an update
  2. If there is, do a unattended update and quitting the application when you make sure that it is updating

I am able to accomplish those on Mac and Linux, but Windows documentation is a mess and QProcess does not look like the way out.

Thank you very much for the help.

Regards, João Mesquita

asked 30 Jan '12, 21:01

JMesquita's gravatar image

JMesquita
21113
accept rate: 0%


The issue is related to UAC feature and is not specific to Qt, but is how Windows Vista and newer versions are designed.

By default the autoupdate binary is set to run as elevated and this is why you cannot run it as on Windows, non-elevated processes cannot run elevated processes for security reasons.

What you can do is set autoupdate binary to run as normal binary and have the installer elevated. You can set the autoupdate not to be elevated by doing:

<autoUpdateProject>
  <shortName>autoupdate</shortName>
  <requestedExecutionLevel>asInvoker</requestedExecutionLevel>
  <!-- any other customizations you might have had for the autoupdate -->
</autoUpdateProject>

And then building the autoupdate binary by doing:

C> path\\to\\autoupdate\\bin\\customize build autoupdate-windows.xml windows

This way the autoupdate binary can be run mechanisms such as QProcess.

However, this will also require that the binary be started as elevated. In this case, autoupdate binary needs to invoke it using "cmd /c start" syntax. It will run the binary using the system shell and prompt the user for elevation (and/or elevated username/password).

This can be done in <postUpdateDownloadActionList>:

<autoUpdateProject>
  <shortName>autoupdate</shortName>
  <requestedExecutionLevel>asInvoker</requestedExecutionLevel>
  <postUpdateDownloadActionList>
    <runProgram>
      <program>cmd</program>
      <programArguments>/c start "${downloadedFilePath.dos}" &amp;</programArguments>
    </runProgram>
  </postUpdateDownloadActionList>
  <!-- any other customizations you might have had for the autoupdate -->
</autoUpdateProject>
link

answered 31 Jan '12, 05:05

wojciechka's gravatar image

wojciechka ♦♦
6.2k4919
accept rate: 26%

Thank you very much! It seems to have worked. At least I can see that it is properly executed and that the exitCode is the proper one. I will try to make a real update and come back to this forum so that ppl can have a sample Qt code that works for learning purposes.

Once again, greatly appreciated. We are evaluating the product and support is always a big plus.

Regards

(31 Jan '12, 16:06) JMesquita
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×22
×8
×7
×6
×2

Asked: 30 Jan '12, 21:01

Seen: 2,522 times

Last updated: 31 Jan '12, 16:24

powered by BitNami OSQA