使用 inno 安装脚本完成安装后,应该如何将文件从安装目录复制到另一个目录?

What should be done to copy files from installed directory to another after installation complete using inno setup script?

先让我知道我的目的。我有一些应用程序正在使用的动态 link 库。根据客户要求,我需要将它们复制到windows的System32目录下。但是我在执行此操作时遇到了一些问题。

我之前已经检查过this link。但我不明白我会修改我的脚本来调用一个在安装后复制文件的函数。即何时、何地以及如何调用这样的函数。

她是我的剧本

#define MyAppName "ABC ToolS"
#define MyAppVersion "1.0"
#define MyAppPublisher "ABC Lab Ltd."
#define MyAppURL "ABC.com"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{399B836A-28F5-4741-A54F-09658DE3E407}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\user06\Desktop
OutputBaseFilename=A
SetupIconFile=C:\Users\user06\Desktop\Release\logo.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Program Files\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\user06\Desktop\Release\A.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\user06\Desktop\Release\B.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; ADDED AS AN EXAMPLE
;If the DLL should be copied to System32 (on both 32 and 64 bit Windows versions)

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{sys}"; Flags: sharedfile 

;If the DLL should be copied to System32 on 32 bit Windows and to SysWOW64 on 64 bit Windows - Do not use this constant unless you have a specific need to obtain the name of the actual directory in which 32-bit system files reside. Gratuitously using {syswow64} in places where {sys} will suffice may cause problems.

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{syswow64}"; Flags: sharedfile 


[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

;[PostIn]

请帮我修改我的脚本,这样我就可以在安装后复制文件了。此外,我还需要在卸载程序时删除它们。但是我找不到任何卸载程序脚本。有人吗?

您必须点 DestDir: "{sys}"(或 DestDir: "{syswow64}" 仅在特殊情况下)

安装程序Compiling后,Source:中指向的所有文件将被集成并存储在Setup.exe中。在安装过程中,Setup.exe 中的所有文件都将被复制到脚本中描述为 DestDir.

的目标文件夹中

示例:

[Files]
;If the DLL should be copied to System32 (on both 32 and 64 bit Windows versions)

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{sys}"; Flags: sharedfile 

;If the DLL should be copied to System32 on 32 bit Windows 
;and to SysWOW64 on 64 bit Windows - Do not use this constant 
;unless you have a specific need to obtain the name of the actual 
;directory in which 32-bit system files reside. 
;Gratuitously using {syswow64} in places where {sys} will suffice 
;may cause problems.

Source: "C:\Users\user06\Desktop\Release\lib\A.dll"; DestDir: "{syswow64}"; Flags: sharedfile