2
votes

I want to write installer for the application which is designed for x64 Windows 10. I have defined in Inno Setup Script:

[Setup]
MinVersion=10.0.14393
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
AlwaysRestart=yes

Also I want that during the installation, long paths will be enabled in Windows registry. I added following code:

[Registry]
Root: HKLM64; Subkey: "System\CurrentcontrolSet\Control\FileSystem"; ValueType: dword; ValueName: "LongPathsEnabled"; ValueData: "1"; Flags: createvalueifdoesntexist; Permissions: users-modify
Root: HKLM64; Subkey: "System\ControlSet001\Control\FileSystem"; ValueType: dword; ValueName: "LongPathsEnabled"; ValueData: "1"; Flags: createvalueifdoesntexist; Permissions: users-modify

When I run the installer on my personal computer and restart, registry entries are changed, but when my colleague runs the installer and restarts, entries are not changed. The application itself works on both our computers. We both have x64 Windows 10 systems and administrator rights. What might be the reasons this script is failing on some computers?

The log file content for the computer, where entries are not changed:

2019-10-09 09:44:41.296   Key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
2019-10-09 09:44:41.296   Value name: LongPathsEnabled
2019-10-09 09:44:41.296   Setting permissions on key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
2019-10-09 09:44:41.296   Starting 64-bit helper process.
2019-10-09 09:44:41.328   Helper process PID: 3248
2019-10-09 09:44:41.343   Creating or opening the key.
2019-10-09 09:44:41.343   Successfully created the key.
2019-10-09 09:44:41.343   -- Registry entry --
2019-10-09 09:44:41.343   Key: HKEY_LOCAL_MACHINE\System\ControlSet001\Control\FileSystem
2019-10-09 09:44:41.343   Value name: LongPathsEnabled
2019-10-09 09:44:41.343   Setting permissions on key: HKEY_LOCAL_MACHINE\System\ControlSet001\Control\FileSystem
2019-10-09 09:44:41.343   Creating or opening the key.
2019-10-09 09:44:41.343   Successfully created the key.
2
What about the PrivilegesRequired flag in the [setup] section? - Andrew Truckle
@AndrewTruckle I set: PrivilegesRequired=admin - Biba
I also added Permissions: users-full admins-full to both entries but still not working :/ - Biba
I generated the log file on the computer where the entry is not changed. I pasted the results to the question. It seems that key is successfully created, but there is no information about setting the value.. - Biba
You do have the flag createvalueifdoesntexist so if the key value is already there it will not be reset to the installer value. - Andrew Truckle

2 Answers

1
votes

Just remove the createvalueifdoesntexist flag.

That's what causes the problem and you do not want it in the first place.

0
votes

What finally seems to be working is checking if the value is already in the register, and if not setting the value with flag createvalueifdoesntexist. Otherwise, the value is jus changed.

[Registry]
Root: HKLM64; Subkey: "System\CurrentControlSet\Control\FileSystem"; ValueType: dword; ValueName: "LongPathsEnabled"; ValueData: "1"; Permissions: users-modify; Flags: createvalueifdoesntexist; Check: LPECurrentControlSetNotInRegistry
Root: HKLM64; Subkey: "System\ControlSet001\Control\FileSystem"; ValueType: dword; ValueName: "LongPathsEnabled"; ValueData: "1"; Permissions: users-modify; Flags: createvalueifdoesntexist; Check: LPEControlSet001NotInRegistry
Root: HKLM64; Subkey: "System\CurrentControlSet\Control\FileSystem"; ValueType: dword; ValueName: "LongPathsEnabled"; ValueData: "1"; Permissions: users-modify; Check: LPECurrentControlSetNotInRegistry
Root: HKLM64; Subkey: "System\ControlSet001\Control\FileSystem"; ValueType: dword; ValueName: "LongPathsEnabled"; ValueData: "1"; Permissions: users-modify; Check: LPEControlSet001NotInRegistry

[Code]
function LPECurrentControlSetNotInRegistry: Boolean;
begin
  if not RegValueExists(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled') then
  begin
    Result := True;
    Exit;
  end;
  Result := False;
end;

function LPEControlSet001NotInRegistry: Boolean;
begin
  if not RegValueExists(HKEY_LOCAL_MACHINE, 'System\ControlSet001\Control\FileSystem', 'LongPathsEnabled') then
  begin
    Result := True;
    Exit;
  end;
  Result := False;
end;