【发布时间】:2015-01-29 09:21:53
【问题描述】:
先告诉你我的目的。我有一些应用程序正在使用的动态链接库。对于客户要求,我需要将它们复制到 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]
请帮我修改我的脚本,以便我可以在安装后复制文件。此外,我还需要在卸载程序时删除它们。但我找不到任何卸载程序脚本。有人吗?
【问题讨论】:
-
但是您要复制哪些文件以及从哪里复制?目标文件夹应该是什么?
-
@RobeN 您可以在我的脚本中看到我已将 A.dll 复制到 app 文件夹。安装后我想将 A.dll 从应用程序复制到 system32。
-
如果您认为将 DLL 复制到 System32 中是正确的解决方案,那么您几乎肯定做错了什么。在 90 年代做这些事情是有原因的,但是(检查日历)它是 2015 年,这是一个属于操作系统的 system 目录,而不是你。
-
所以只需指向
DestDir: "{sys}"或DestDir: "{syswow64}",但您应该另外设置Flags: sharedfile onlyifdoesntexist,特别是如果您的DLL 可以被其他软件使用或可能已经安装。有关详细信息,请参阅 Inno Setup 文档中的Constants和[Files] section。 -
这就是它的工作原理。您在计算机上编译安装程序,然后 DLL 文件已包含在 Setup.exe 中。运行后,DLL 文件将从 Setup.exe 提取到系统文件夹。
Source在编译命令中指向将被编译到 Setup.exe 中的文件。你不使用Flags: external。