Qt Installer Framework: Cannot uninstall program on Windows 10
-
Hi,
I have created an installer for my program with Qt Installer Framework 3.0.6.
It all works fine on Windows 7.
On Windows 10 however, I can't run the uninstaller from the "Uninstall or change a program" menu. When I select my program in the list and click "Uninstall", I get the following error: "This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel". It works as expected if I manually launch uninstall.exe.
Is an additional step necessary to work with Windows 10?
Thanks for the help.
-
Hi and welcome to devnet forum
In this case you do the uninstall directly from windows 10?
You can start maintenancetool.exe in the installation folder of your application. There should be the entrance for complete removal of the application. I am using always that part.
-
Thanks for the answer.
Starting the uninstaller.exe by double click from my program installation directory works fine. It removes all the file and my program is gone from the installed programs list. The main problem is that my users try to remove the program from the "Uninstall or change a program" menu (as we all do) and in that case it doesn't work (it shows the message above).
-
Months later, I found the problem.
The installer framework creates an entry in "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall". My"UninstallString" key contained spaces (because my application name had spaces, but I suppose if you install in "Program Files" the problem would be the same).
On Windows 7 there is no problem, but Windows 10 does not accept the path with spaces. When I manually change the UninstallString value with regedit to add quotes before and after, everything works as expected.
I didn't find how to change that in the installer framework so I created a batch script that will find this UninstallString key and add quotes before and after. This script is executed at the end of the installation.
I am really not good at batch scripting, but in case someone encounters the same problem here is my quick and dirty script:
@echo off REM This scripts looks for the path to the uninstall program of the first parameter. REM If the version of the program matches the second parameter, the uninstall path is updated to add quotes at the beginning and at the end. set APP_NAME=%~1 set VERSION=%~2 REM Loop through all the uninstall entries for /f "tokens=1 usebackq" %%a in (`reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"`) do ( for /f "usebackq tokens=2*" %%b in (`REG QUERY "%%a" /v "DisplayName"`) do ( REM %%c is the application name if "%%c"=="%APP_NAME%" ( for /f "usebackq tokens=2*" %%d in (`REG QUERY "%%a" /v "DisplayVersion"`) do ( REM %%e is the version if %%e==%VERSION% ( echo Found %APP_NAME% %%e REM Add quotes before and after the path for /f "usebackq tokens=2*" %%i in (`REG QUERY "%%a" /v "UninstallString"`) do ( REM %%j is the uninstaller path reg add %%a /v UninstallString /d "\"%%~j\"" /f > nul ) ) else ( echo Incompatible version %%c. Expected: %VERSION% ) ) ) ) )
To execute it at the end of the installation, I added this to my install script file:
installer.installationFinished.connect(this, Controller.prototype.doPostInstallAction);
Controller.prototype.doPostInstallAction = function() { if (installer.isInstaller()) { console.log("----- Fixing uninstaller path"); var scriptFilePath = TempInstallDir + "update-uninstall-path.bat"; installer.performOperation("Copy", ["://update-uninstall-path.bat", scriptFilePath]); installer.performOperation("Execute", [scriptFilePath, "@ProductName@", "@ProductVersion@" ]); } }
In my installer, update-uninstall-path.bat is added to the QRC file.
Now after installing my program the quotes are automatically added and I can successfuly uninstall my program on Windows 10.
-
Thanks for reporting back. However,it would be good to checkin the bug report system for Qt https://bugreports.qt.io/secure/Dashboard.jspa if there is already a bug report on this issue. If not,you should add it and post the bug report number here.
This forum is not checked for bug reports and it will be lost when not entered as a proper bug report.
-
FWIW, it seems to work fine in Win10 and IFW 4.0.0 these days, even when the string contains spaces (i.e. installed in c:\program files...).