Preventing Inno Setup from uninstalling empty directories created with createallsubdirs flag

Tim Earl

I have a folder (database folder) that I would like to keep after uninstall (for saving users data and future reinstall), I have flagged top folder to never uninstall as well as all its files (and folders?) whether empty or not yet Inno Setup deletes these empty sub-folders (which I want to keep) during uninstall. Do I have to declare all the sub folders I want to keep or is their a flag I am missing?

[Dirs]
Name: "{app}\db\data"; Flags: uninsneveruninstall; Permissions: everyone-full

[Files]
Source: "D:\sesam\db\data\*"; DestDir: "{app}\db\data"; Flags: recursesubdirs createallsubdirs uninsneveruninstall; Check: CheckNotExists(ExpandConstant('{app}\db\data'))

Before uninstall and after:

enter image description here enter image description here

As you can see it only keeps "non empty" folders.

Martin Prikryl

Looks like a bug to me, consider reporting it.


Anyway, you can use the Inno Setup preprocessor to generate a list of [Dirs] entries for each subfolder:

[Dirs]
#define FindHandle
#define FindResult
#define SourceDataPath "D:\sesam\db\data"
#define TargetDataPath "{app}\db\data"

#sub ProcessFoundFile
  #define DirName FindGetFileName(FindHandle)
  #define DirPath SourceDataPath + "\" + DirName
  #if DirExists(DirPath) && (DirName != ".") && (DirName != "..")
    Name: "{#TargetDataPath + "\" + DirName}"; Flags: uninsneveruninstall
  #endif
#endsub

#for {FindHandle = FindResult = FindFirst(SourceDataPath + "\*", faDirectory); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#expr FindClose(FindHandle)

The above works for single-level only. If you need recursion, it's more complicated.


Put this at the end of your script to see and review, what the preprocessor generated:

#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Signing files using Inno Setup with the signonce flag

From Dev

Inno Setup "deleteafterinstall" flag: What happens if file is locked?

From Dev

Inno Setup create TStringList from CDATA

From Dev

Set Windows file version for a setup file created by Inno Setup

From Dev

How to call "npm install" from Inno Setup?

From Dev

Inno Setup skip memo page if empty

From Dev

Inno Setup loop from A to Z

From Dev

inno setup - Delete arbitrary substring from a string

From Dev

Running netsh from using Inno Setup Exec()

From Dev

Multi-line edit in Inno Setup on page created by CreateInputQueryPage

From Dev

Empty game folder stays after uninstallation - Inno Setup

From Dev

Create ZIP files from within Inno Setup

From Dev

Import a scheduled task from XML in Inno Setup

From Dev

Inno Setup - Remove path from PATH environment variable while uninstalling a program

From Dev

How to find an unique name to rename/archive old directories in Inno Setup

From Dev

Call Function From Procedure in Inno Setup?

From Dev

Preventing pytest from creating .cache directories in Pycharm

From Dev

Inno Setup: Delete empty lines from test file

From Dev

Uninstalling using setup.exe

From Dev

Preventing Empty Data from Inserting into database

From Dev

Inno setup Arabic directories name error

From Dev

Detect and remove empty directories from list

From Dev

Write to console from a native javafx app created with Inno Setup and maven

From Dev

Empty game folder stays after uninstallation - Inno Setup

From Dev

Prevent button from receiving focus in Inno Setup

From Dev

How to run batch while installing and uninstalling with Inno Setup

From Dev

Inno Setup - How to create a new uninstalling page in a custom uninstall page?

From Dev

Inno Setup unzip file from input user

From Dev

Inno Setup Finding folder and using multiple choice of directories

Related Related

  1. 1

    Signing files using Inno Setup with the signonce flag

  2. 2

    Inno Setup "deleteafterinstall" flag: What happens if file is locked?

  3. 3

    Inno Setup create TStringList from CDATA

  4. 4

    Set Windows file version for a setup file created by Inno Setup

  5. 5

    How to call "npm install" from Inno Setup?

  6. 6

    Inno Setup skip memo page if empty

  7. 7

    Inno Setup loop from A to Z

  8. 8

    inno setup - Delete arbitrary substring from a string

  9. 9

    Running netsh from using Inno Setup Exec()

  10. 10

    Multi-line edit in Inno Setup on page created by CreateInputQueryPage

  11. 11

    Empty game folder stays after uninstallation - Inno Setup

  12. 12

    Create ZIP files from within Inno Setup

  13. 13

    Import a scheduled task from XML in Inno Setup

  14. 14

    Inno Setup - Remove path from PATH environment variable while uninstalling a program

  15. 15

    How to find an unique name to rename/archive old directories in Inno Setup

  16. 16

    Call Function From Procedure in Inno Setup?

  17. 17

    Preventing pytest from creating .cache directories in Pycharm

  18. 18

    Inno Setup: Delete empty lines from test file

  19. 19

    Uninstalling using setup.exe

  20. 20

    Preventing Empty Data from Inserting into database

  21. 21

    Inno setup Arabic directories name error

  22. 22

    Detect and remove empty directories from list

  23. 23

    Write to console from a native javafx app created with Inno Setup and maven

  24. 24

    Empty game folder stays after uninstallation - Inno Setup

  25. 25

    Prevent button from receiving focus in Inno Setup

  26. 26

    How to run batch while installing and uninstalling with Inno Setup

  27. 27

    Inno Setup - How to create a new uninstalling page in a custom uninstall page?

  28. 28

    Inno Setup unzip file from input user

  29. 29

    Inno Setup Finding folder and using multiple choice of directories

HotTag

Archive