How to delete a nonempty folder in inno setup

beginner

I have created an installer using Inno Setup which contains 5 files in it. I have added an additional feature so that user can install it in custom path.

After installing, a folder will be created in selected path. Now I will copy some other files in this folder. But after un-installation the following cases are happening:

  1. let user installs it in default location, then a new folder say myfolder is created in that location, now user creates 2 new files and copies them in this folder. After un-installing there is no problem; myfolder will be deleted along with 2 new files(which are created after installing).

  2. now let user install it in custom location, then a new folder say myfolder is created in that location, now user creates 2 new files and copies them in this folder. after uninstalling myfolder is not deleting since 2 new files in it (which are created after installing).

Here is my code:

function GetInstalledLocation(): String;
var
installLocation: String;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\   {36CBFC-6ACC-4232-90CF-E95BC473C168}_is1') then
   begin
   RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1536CBFC-6ACC-4232-90CF-E95BC473C168}_is1', 'InstallLocation', installLocation);
   Result := installLocation
  end; 
 end;



function InitializeUninstall(): Boolean;
var
  InstalledLocation : String;
  begin
   Result := PromptUntilProgramClosedOrInstallationCanceled( ProgramRunningOnUninstallMessage, True );

   // Unload the DLL, otherwise the dll psvince is not deleted
       UnloadDLL(ExpandConstant('{app}\psvince.dll'));

        if not Result then
        begin
          MsgBox( UninstallationCanceledMessage, mbInformation, MB_OK );
          end
            else
         begin
         InstalledLocation := GetInstalledLocation();
          ;DelTree('{InstalledLocation\*}', True, True, True);
            DelTree('{InstalledLocation}', True, True, True);
          ; DelTree('ExpandConstant({InstalledLocation\*})', True, True, True);
             end;
              end;

          [UninstallDelete]
             ;This works only if it is installed in default location
            Type: filesandordirs; Name: "{pf}\{#MyAppName}"

But I want to delete the folder along with the new files i.e. I want to delete nonempty folder in inno setup . How can I do it ?

beginner

ya now its working , i used following code :

[UninstallDelete]
;This works only if it is installed in default location
Type: filesandordirs; Name: "{pf}\{#MyAppName}"


;This works if it is installed in custom location
Type: files; Name: "{app}\*"; 
Type: filesandordirs; Name: "{app}"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Inno Setup: pack folder with all subfolders

From Dev

Inno-setup pack all files in a folder exept for 1 file

From Dev

How to test if FileExists in folder where Inno Setup is running?

From Dev

Should Inno Setup delete old files on Update?

From Dev

How to override functions in Inno Setup?

From Dev

How to split a string in Inno Setup

From Dev

Inno Setup: Delete folder with Task function

From Dev

How to disable OK button in "Browse For Folder" dialog in Inno Setup

From Dev

Avoiding "Failed to expand shell folder constant userdocs" errors in Inno Setup

From Dev

how to refresh a page in inno setup

From Dev

Inno Setup CreateInputDirPage but don't check for folder existence

From Dev

inno setup - Delete arbitrary substring from a string

From Dev

Inno Setup [UninstallDelete] delete all except one folder

From Dev

Inno Setup: Get 'Don't create a start menu folder' option

From Dev

Inno Setup: copy folder, subfolders and files recursively in Code section

From Dev

Empty game folder stays after uninstallation - Inno Setup

From Dev

Inno Setup - How to set permissions of installation folder

From Dev

Inno Setup - Get a path to parent folder

From Dev

Renci SSH.NET: How to delete nonempty directory?

From Dev

Creating shortcut in startup folder using Inno setup

From Dev

Inno-setup pack all files in a folder exept for 1 file

From Dev

Should Inno Setup delete old files on Update?

From Dev

Inno Setup: How to let Folder.CopyHere finish copying before moving to the next folder?

From Dev

How to extract a Inno Setup Installer

From Dev

Inno Setup: Get 'Don't create a start menu folder' option

From Dev

Empty game folder stays after uninstallation - Inno Setup

From Dev

Checking existence of a file in Inno Setup Internal Temporary folder

From Dev

Inno Setup shortcuts for folder are not opening in Windows 10

From Dev

Inno setup - how to change version in the setup hover?

Related Related

  1. 1

    Inno Setup: pack folder with all subfolders

  2. 2

    Inno-setup pack all files in a folder exept for 1 file

  3. 3

    How to test if FileExists in folder where Inno Setup is running?

  4. 4

    Should Inno Setup delete old files on Update?

  5. 5

    How to override functions in Inno Setup?

  6. 6

    How to split a string in Inno Setup

  7. 7

    Inno Setup: Delete folder with Task function

  8. 8

    How to disable OK button in "Browse For Folder" dialog in Inno Setup

  9. 9

    Avoiding "Failed to expand shell folder constant userdocs" errors in Inno Setup

  10. 10

    how to refresh a page in inno setup

  11. 11

    Inno Setup CreateInputDirPage but don't check for folder existence

  12. 12

    inno setup - Delete arbitrary substring from a string

  13. 13

    Inno Setup [UninstallDelete] delete all except one folder

  14. 14

    Inno Setup: Get 'Don't create a start menu folder' option

  15. 15

    Inno Setup: copy folder, subfolders and files recursively in Code section

  16. 16

    Empty game folder stays after uninstallation - Inno Setup

  17. 17

    Inno Setup - How to set permissions of installation folder

  18. 18

    Inno Setup - Get a path to parent folder

  19. 19

    Renci SSH.NET: How to delete nonempty directory?

  20. 20

    Creating shortcut in startup folder using Inno setup

  21. 21

    Inno-setup pack all files in a folder exept for 1 file

  22. 22

    Should Inno Setup delete old files on Update?

  23. 23

    Inno Setup: How to let Folder.CopyHere finish copying before moving to the next folder?

  24. 24

    How to extract a Inno Setup Installer

  25. 25

    Inno Setup: Get 'Don't create a start menu folder' option

  26. 26

    Empty game folder stays after uninstallation - Inno Setup

  27. 27

    Checking existence of a file in Inno Setup Internal Temporary folder

  28. 28

    Inno Setup shortcuts for folder are not opening in Windows 10

  29. 29

    Inno setup - how to change version in the setup hover?

HotTag

Archive