Use "Program Files" directory on both 32-bit/64-bit systems with Inno Setup {pf}

The constant {pf} is the directory of

C:\Program Files

for 32-bit systems and

C:\Program Files (x86)

for 64-bit systems.

However I want to use the directory

C:\Program Files

for both, 32 and 64-bit systems. How can I achieve this?


  • Use a scripted constant like:

    DefaultDirName={code:GetProgramFiles}\My Program
    function GetProgramFiles(Param: string): string;
      if IsWin64 then Result := ExpandConstant('{commonpf64}')
        else Result := ExpandConstant('{commonpf32}')

    Though this approach should only be used, if you generate binaries for the respective platform on the fly. Like in your case, if understand correctly, you compile the Java binaries for the respective architecture.

    You can also use 64-bit install mode.

    Then you can simply use {autopf} constant (previously {pf}):

    DefaultDirName={autopf}\My Program

    If you have a separate 32-bit and 64-bit binaries in the installer, use a script like:

    Source: "MyDll32.dll"; DestDir: "{pf32}\My Program"; Check: not IsWin64
    Source: "MyDll64.dll"; DestDir: "{pf64}\My Program"; Check: IsWin64

    See also: