Qt Installer Framework provides a simple way of creating cross-platform installers and setup files. Some of the questions that are asked quite a lot, but unfortunately are not as well-documented as they should be, is about the “Execute” method which is used to run executable files during installation. In this post I’ve tried to clarify a couple of points about it with a couple of simple examples.
First of all, you can use this link to access detailed information about Qt Installer Framework Operations. The operation that we are interested in is the Execute operation and you can find relatively simple examples about how it’s used in the same link.
The one case this post is mostly about, is the case where the return value of the executable might be different than zero, so you’ll need to explicitly allow all result values that you consider as successful.
For instance, when running Visual C++ Redistributable Packages during installation of Windows applications, you might want to ignore a couple of error codes, such as the ones below:
- 1602: Happens when the installation of Redistributable Package is cancelled.
- 1638: Happens when another version of the Redistributable Package is already installed.
Assuming vc_redist.x86.exe (Visual C++ Redistributable Packages for x86) is included in the installation target folder, you can run something like the following command in your Qt Installer Framework script to take care of the preceding error codes in addition to successful installation:
component.addOperation("Execute", "{0,1602,1638}", "@TargetDir@\\vc_redist.x86.exe", "/passive", "/norestart");
If you need to run the installer with elevated permissions (which usually is the case), you can use the following code instead:
component.addElevatedOperation("Execute", "{0,1602,1638}", "@TargetDir@\\vc_redist.x86.exe", "/passive", "/norestart");
Qt Installer Framework 3.1 was used to test the codes in this post but they should work in previous versions of Qt Installer Framework as well, perhaps even without any modification.
An installer is sometimes forgotten and in need of some love as the first interaction a user will have with your desktop application, crucial, required, and preferably welcome. So, to give it its due, here’s a quick rundown of a tool that might be useful: Qt Installer Framework is a framework for installing Qt applications.