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;