I want to use script like below
function InitializeSetup(): Boolean;
begin
  Result := not IsAdminLoggedOn;
  if Result then
  begin
to check if the user is administrator or not.
But how can I do if user is administrator, then install A.txt in C:\program files\ABC, otherwise in D:\TEST?
Can I write something to connect to [Files]?
Because I also want to use check path when installing files, if I can combine [Code] and [Files] it might be easier for me.
Excuse for my lack of knowledge, and thanks in advance.
I've tried to use this,
[Files]
Source: "..\ABC\CDE.txt"; DestDir: "{code:GetDirName}\IJK"; \
    Check: DirExists(ExpandConstant('C:\Program Files\FGH'))
But I don't know how to write the code, if I want to install more files in more path.
This one doesn't work:
function GetDirName(Param: string): string;
begin
  if IsAdminLoggedOn And DirExists(ExpandConstant('C:\ABC')) then
  begin
    Result := ExpandConstant('C:\ABC\My Program')
  end
    else
  begin
    if DirExists(ExpandConstant('C:\DEF')) then
    begin
      Result := ExpandConstant('C:\DEF\My Other Program');
    end
      else
    begin
      MsgBox('No destination found, aborting installation', mbError, MB_OK);
    end;
  end;
end;
				
                        
Just implement the
GetDirNamescripted constant to return a different path for privileged and un-privileged installation.If you want to use different folders for different files, just implement more functions like
GetDirName. Though if the difference is only about subfolders, you can of course use one scripted constant function to resolve the common root folder and append the subfolder in theDestDirparameter.If you want to change an overall installation target, use the
GetDirNamescripted constant in theDefaultDirNamedirective:For a more complex example, see Make Inno Setup installer request privileges elevation only when needed.