2016-04-29 5 views
1

{app}ディレクトリのアドオンフォルダ/ファイルをInno Setupインストーラ内の別のフォルダProgram Filesにコピーしようとしています。 xcopyを使用してシェルコマンドを実行するコードを記述しましたが、動作させることができません。私は、パーミッションが賢明だと思うすべてを試しました(shellexecasoriginaluserFlag = runasoriginaluserPrivilegesRequired=admin)。手で入力してcmdで実行すると正常に動作するため、アクセス許可の問題であると仮定していますか?何か案は?Inno Setupでシェルxcopyコマンドを使用する

コード:

[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; 

答えて

1
  • FileName引数のみxcopy(というかxcopy.exe)でなければなりません。
  • 残りのコマンドラインはParams引数になります。
  • echo offパラメータはナンセンスです。
  • xcopyShellExecを使用すると、オーバーキルです。プレーンExecを使用してください。
Exec('xcopy.exe', '/E /I ...', ...) 

ものの、より良いエラー制御のため、あなたはより良いネイティブパスカルスクリプト機能を使用します。
Inno Setup: copy folder, subfolders and files recursively in Code section


そして最後に、最も簡単かつ最良の方法、具体的なケースについては、scripted constant[Files]セクションのエントリを使用してください:

[Files] 
Source: "..\Dialogs\*"; DestDir: "{app}\Dialogs"; Flags: ignoreversion recursesubdirs 64bit; 
Source: "..\Dialogs\*"; DestDir: "{code:GetStatisticsInstallationFolder}"; Flags: ignoreversion recursesubdirs 64bit; 

[Code] 

function GetStatisticsInstallationFolder(Param: String): String; 
begin 
    Result := SelectStatisticsFolderPage.Values[0]; 
end; 
+0

ありがとうございます!私はこれ以上数時間トールした –

+0

あなたは大歓迎です。私はまだあなたの特別な必要性のためのより良い方法があることを認識しましたが。私の更新された答えを見てください。 –

関連する問題