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

时间:2015-01-29 09:21:53

标签: installer inno-setup

首先告诉我你的目的。我有一些应用程序使用的动态链接库。对于客户端要求,我需要将它们复制到Windows的System32目录中。但是我要面对一些问题。

我之前已经检查了this链接。但是我无法理解我会修改我的脚本以调用安装后复制文件的函数。即何时,何地以及如何调用这样的函数。

她是我的剧本

#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]

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

1 个答案:

答案 0 :(得分:2)

您必须指出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