Manual entry of the destination directory (DefaultDirName)

36 views
Skip to first unread message

Jan Bleiss

unread,
Nov 10, 2025, 12:51:01 PMNov 10
to innosetup
Hi,
In my installers, I use this entry for the line directory: DefaultDirName={code:GetDefDir}
This entry accesses this software:

[Code]
function GetDefDir(Param: String): String;
Begin
If IsWin64 then begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, “SOFTWARE\WOW6432Node\railsimulator.com\RailWorks”,'Install_Path',Result);
end
Else begin
Result := “c:\program files(x86)\steam\steamApps\common\railworks”;
end;
end;

The installer runs without asking the user for the installation directory. However, I would like it to do so in case the registry does not contain what it should. Which command can I use to make the setup ask for the destination folder in any case, but with the entry found in the registry as the default value?

Thanks, Jan

Jernej Simončič

unread,
Nov 10, 2025, 2:43:59 PMNov 10
to Jan Bleiss on [innosetup]

On Monday, November 10, 2025, 18:49:43, Jan Bleiss wrote:


The installer runs without asking the user for the installation directory. However, I would like it to do so in case the registry does not contain what it should. Which command can I use to make the setup ask for the destination folder in any case, but with the entry found in the registry as the default value?

Make sure you're doing a clean install; by default if you ran Setup with the same AppId before, Inno will skip the directory page, and automatically use the previous installation path.

 

-- 
< Jernej Simončič ><><><><>< https://eternallybored.org/ >


If the experiment works, you must be using the wrong equipment.
       -- Patrick's Theorem

Gavin Lambert

unread,
Nov 16, 2025, 6:45:06 PM (11 days ago) Nov 16
to innosetup
On Tuesday, November 11, 2025 at 6:51:01 AM UTC+13 Jan Bleiss wrote:
If IsWin64 then begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, “SOFTWARE\WOW6432Node\railsimulator.com\RailWorks”,'Install_Path',Result);
end
Else begin
Result := “c:\program files(x86)\steam\steamApps\common\railworks”;
end;

This code is nonsensical.

Remove the "WOW6432Node" part of the path and use HKLM32 as the root, and then you can remove the IsWin64 condition.  You also have the wrong quotes in this registry path, and your fallback path is completely invalid anyway (you should be using ExpandConstant with {pf32} instead of hard-coding the wrong path to Program Files -- and you should probably be searching for the Steam install dir as a fallback rather than hard-coding that at all).  You should also be using the fallback path when the RegQuery fails.
Reply all
Reply to author
Forward
0 new messages