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

Installation 使用inno安装脚本完成安装后,应如何将文件从安装目录复制到另一个目录?,installation,inno-setup,Installation,Inno Setup,让我先告诉你我的目的。我有一些应用程序正在使用的动态链接库。对于客户端要求,我需要将它们复制到windows的System32目录。但我在这方面面临一些问题 我以前已经检查过链接。但我不明白我将修改我的脚本以调用一个函数,该函数在安装后复制文件。i、 e.何时、何地以及如何调用这样的函数 她是我的剧本 #define MyAppName "ABC ToolS" #define MyAppVersion "1.0" #define MyAppPublisher "ABC Lab Ltd." #de

让我先告诉你我的目的。我有一些应用程序正在使用的动态链接库。对于客户端要求,我需要将它们复制到windows的System32目录。但我在这方面面临一些问题

我以前已经检查过链接。但我不明白我将修改我的脚本以调用一个函数,该函数在安装后复制文件。i、 e.何时、何地以及如何调用这样的函数

她是我的剧本

#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}”
仅在特殊情况下)

编译安装程序后,
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 

但是你想从哪里复制什么文件?目标文件夹应该是什么?@RobeN您可以在我的脚本中看到,我已将一个.dll复制到app文件夹。安装后,我想将.dll从app复制到system32。如果您认为将dll复制到system32是正确的解决方案,那么您几乎肯定是做错了什么。早在90年代就有这样做的原因,但(检查日历)是2015年,这是属于操作系统的系统目录,而不是您的。所以只需指向
DestDir:{sys}
DestDir:{syswow64}
,但是您应该另外设置
标志:sharedfile OnlyIfdoesntextist
,特别是当您的DLL可能被其他软件使用或可能已经安装时。请参阅Inno Setup文档中的
常量
[文件]部分
,了解更多信息。这就是它的工作原理。在计算机上编译安装程序,则DLL文件已包含在Setup.exe中。运行后,DLL文件将从Setup.exe提取到系统文件夹
Source
指向将在Compile命令上编译到Setup.exe中的文件。您不使用
标志:外部
。我尝试使用Source:“D:\test.dll;DestDir:{sys}”;标志:sharedfile,但文件会复制到syswow64而不是system32文件夹。请帮助如果您以32位模式运行安装程序(默认),则
{sys}
将扩展为
syswow64
。以便扩展
{sys}
作为C:\WINDOWS\SYSTEM,您必须以64位模式运行安装程序。更多信息请参阅