I am trying to copy add-on folders/files from the {app}
directory to a different folder in Program Files
within an Inno Setup installer. I have written some code to execute a shell command to do so using xcopy
but I cannot get it to work. I have tried all that I can think of permissions wise (shellexecasoriginaluser
, Flag
=runasoriginaluser
, PrivilegesRequired=admin
). If I type it by hand and run it in cmd
it works fine, so one assumes it must be a permissions issue? Any ideas?
Code:
[Files]
Source: "..\Dialogs\*";DestDir: "{app}\Dialogs"; Flags: ignoreversion recursesubdirs 64bit; AfterInstall: WriteExtensionsToInstallFolder();
[Code]
procedure WriteExtensionsToInstallFolder();
var
StatisticsInstallationFolder: string;
pParameter: string;
runline: string;
ResultCode: integer;
begin
StatisticsInstallationFolder := SelectStatisticsFolderPage.Values[0];
pParameter := '@echo off' + #13#10
runline := 'xcopy /E /I /Y "' + ExpandConstant('{app}') + '\Dialogs\*" "' + ExpandConstant(StatisticsInstallationFolder) + '\ext"'
if not ShellExec('',runline, pParameter, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Could not copy plugins' + IntToStr(ResultCode) ,mbError, mb_Ok);
end;
end;