Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt Installer Framework: Cannot uninstall program on Windows 10
QtWS25 Last Chance

Qt Installer Framework: Cannot uninstall program on Windows 10

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
6 Posts 3 Posters 4.3k Views
  • 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.
  • D Offline
    D Offline
    Dydill
    wrote on 22 Dec 2018, 12:34 last edited by
    #1

    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.

    K 1 Reply Last reply 22 Dec 2018, 12:54
    0
    • D Dydill
      22 Dec 2018, 12:34

      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.

      K Offline
      K Offline
      koahnig
      wrote on 22 Dec 2018, 12:54 last edited by
      #2

      @Dydill

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • D Offline
        D Offline
        Dydill
        wrote on 22 Dec 2018, 14:22 last edited by
        #3

        @koahnig

        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).

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dydill
          wrote on 21 Jul 2019, 13:59 last edited by Dydill
          #4

          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.

          K 1 Reply Last reply 21 Jul 2019, 16:49
          1
          • D Dydill
            21 Jul 2019, 13:59

            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.

            K Offline
            K Offline
            koahnig
            wrote on 21 Jul 2019, 16:49 last edited by
            #5

            @Dydill

            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.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            1
            • M Offline
              M Offline
              Marcus Sonestedt
              wrote on 1 Mar 2021, 07:18 last edited by
              #6

              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...).

              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