Handling dynamic folders change during installation in Inno Setup 7

67 views
Skip to first unread message

Jack Gray (Fixxxer)

unread,
Aug 7, 2026, 8:11:26 AMAug 7
to innosetup
Hi All.

Maybe I have called the topic incorrectly so I will do my best to explain what I mean.

I have an installer code that handles user's input for possible overwriting default files by the files from the backup folder. This folder user selects during installation - but there could be cases of "clean install" when user selects nothing.

So I have:

[Files]
Source: "C:\MySource\*"; Excludes: "temp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{code:GetBackupFolderPage}"; DestDir: "{app}\Common"; Flags: external skipifsourcedoesntexist recursesubdirs
....
[Code]
...
function GetBackupFolderPage(Param: string): string;
var Path: string;
begin
  Path := Page.Values[0];
  If Path = '' then Result := '' else Result := Path + '\*';
end;

It works like a charm in Inno 6, but Inno 7 creates installer that causes "PathRedir: Called with empty path string." error.
Obviously it caused by inproper handling "skipifsourcedoesntexist" and "createallsubdirs" in "Files" section.

Martijn Laan - Inno Setup

unread,
Aug 9, 2026, 2:40:25 AMAug 9
to innosetup
Hi,

Op 7-8-2026 om 14:00 schreef Jack Gray:
Source: "{code:GetBackupFolderPage}"; DestDir: "{app}\Common"; Flags: external skipifsourcedoesntexist recursesubdirs
....
[Code]
...
function GetBackupFolderPage(Param: string): string;
var Path: string;
begin
  Path := Page.Values[0];
  If Path = '' then Result := '' else Result := Path + '\*';
end;

It works like a charm in Inno 6, but Inno 7 creates installer that causes "PathRedir: Called with empty path string." error.

Source is a required parameter and not allowed to be empty. It doesn't work like a charm in Inno Setup 6: your Setup walks the entire Windows system directory tree if the user enters no backup folder. And had the entry also included createallsubdirs, it would have recreated that whole tree as empty directories inside your application folder, each one recorded for uninstall.

Inno Setup 7 refuses the empty path instead of doing that walk or structure copy. I will look into giving a more clear error.

To get rid of the error/walk, the script needs to have a Check parameter like this, both in 6 and 7:

Source: "{code:GetBackupFolderPage}"; DestDir: "{app}\Common"; \
  Check: HaveBackupFolder; Flags: external skipifsourcedoesntexist recursesubdirs

function HaveBackupFolder: Boolean;
begin
  Result := (Page <> nil) and (Page.Values[0] <> '');
end;

function GetBackupFolderPage(Param: string): string;
begin
  Result := Page.Values[0] + '\*';
end;

Greetings,
Martijn

gjf.f...@gmail.com

unread,
Aug 9, 2026, 8:29:01 AMAug 9
to inno...@googlegroups.com

Hm, it makes sense.


Thank you very much for your help and suggestion!


Martijn --
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/dfV8YH2h3IM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/178625761873.7.6646373147415115878.1537493331%40innosetup.nl.

Gavin Lambert

unread,
Aug 10, 2026, 12:48:35 AMAug 10
to innosetup
On Saturday, August 8, 2026 at 12:11:26 AM UTC+12 Jack Gray (Fixxxer) wrote:
I have an installer code that handles user's input for possible overwriting default files by the files from the backup folder. This folder user selects during installation - but there could be cases of "clean install" when user selects nothing.

FYI, this is not recommended practice for Windows apps.  Ideally you should keep all files in {app} and below read-only to all users -- at most installing template files there, which can always be safely overwritten.

At runtime, your app should try to read user-editable configs from *all* of these places, merging or overwriting settings as appropriate (typically topmost wins):
  1. Per-user settings from HKCU\YourCompany\YourApp or {userappdata}\YourApp.
  2. Per-machine settings from HKLM\YourCompany\YourApp or {commonappdata}\YourApp.
  3. Default settings compiled-in (or only if you really must, in {app}).
i.e. non-admin users must not be able to edit configs in {app}, and while admins could, you should prefer to have them use the per-user or per-machine settings locations as appropriate.

At (un)install time, you typically don't touch any of these configuration paths, to avoid clobbering custom settings and preserving them for the people who like periodically uninstalling and reinstalling apps.

gjf.f...@gmail.com

unread,
Aug 10, 2026, 6:17:59 AMAug 10
to inno...@googlegroups.com

Yes, I know it is not the best practice to allow user have an access to admin-only restricted folders - even through installer.

However, this is very specific application: it is installer of software that operates an instrument. Because it is necessary to store both serial number and calibration file those are specific to the exact instrument - it is necessary to develop such "backup" option.

Don't ask me why software developer didn't designed correct position of these files rather than in program dir - I am not that guy.


From: Gavin Lambert [mailto:i...@mirality.co.nz]
Sent: Monday, August 10, 2026 07:48 AM +03
To: innosetup
Subject: Re: Handling dynamic folders change during installation in Inno Setup 7

--
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/dfV8YH2h3IM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages