Inno Setup:将文件复制到用户定义的多个目的地

发布于 2024-09-16 20:09:30 字数 1820 浏览 3 评论 0原文

在安装过程中,用户可以安装一些服务实例(Service1-ServiceN)。这些服务之间的所有差异 - 配置文件的内容(实际上 /Product_Root/run 中只有一个可执行文件,使用不同的命令行参数调用)。配置文件位于 ProductRoot/ServiceX/conf 中。

文件夹结构如下所示:

/Product_Root
----/bin
----/doc
----/Service1
---------/conf
----/Service2
---------/conf
...
----/ServiceN
---------/conf

例如,在 ProductRoot/ServiceX/conf 中,包含以下内容的 service.properties 文件:

#...
ServiceRoot = <%ROOT_DIRECTORY%>
ListenPort = <%PORT%>
#...

另外,在 /Product_Root/bin 中应该存在每个服务启动的脚本: 例如:

/Product_Root/bin/Service1.run.cmd
/Product_Root/bin/Service2.run.cmd
...
/Product_Root/bin/ServiceN.run.cmd
...

脚本文件结构为:

service.exe ../<%SERVICE_NAME%>/conf/service.properties

所有值(如 <%SERVICE_NAME%>、<%PORT%> 等)均由用户在每个服务的设置过程中设置。 服务数量也由用户设置,可能在 1(默认情况下)和 20-30 之间变化。

如果是单一服务 - 没有问题。

正在复制的文件、使用

[Files]
Source: {#FilesPath}\bin\*.*; DestDir: {app}\{#FileLocationPrefix}\bin; Flags: ignoreversion restartreplace
Source: {#АilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}\{code:GetServiceName}\conf; Flags: ignoreversion recursesubdirs createallsubdirs restartreplace; 

[Dirs]
Name: {app}\{#FileLocationPrefix}{code:GetServiceName}\conf

ssPostInstall 步骤中的 After 通配符创建的目录替换在复制的文件中执行。

问题。

在服务数量较多的情况下,是否可以使用 Inno Setup + ISTool 执行相同的操作?

例如:

[Files]
#for (i = 0; i < ServiceCount(); ++i) 
Source: {#АilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}\{code:GetServiceName| i}\conf; Flags: ignoreversion recursesubdirs createallsubdirs

其中 i — 实际上是配置号。 即,是否可以使用在安装过程中从用户那里收到的信息在 [File]、[Dirs] 等部分中对不同目录中的相同文件进行多次复制? 用于在安装过程中复制用户设置的多个具有不同名称的文件中的单个文件?

或者我只是走错了方向?

During installation process user has ability to install number of some service instances (Service1- ServiceN). All the differences between these services - content of configuration files(actually there is only one executable in /Product_Root/run wich is called with different command-line params).Configuration files situated in ProductRoot/ServiceX/conf.

Folders structure looks like :

/Product_Root
----/bin
----/doc
----/Service1
---------/conf
----/Service2
---------/conf
...
----/ServiceN
---------/conf

In ProductRoot/ServiceX/conf is situated, for example, service.properties file with these contents:

#...
ServiceRoot = <%ROOT_DIRECTORY%>
ListenPort = <%PORT%>
#...

Also in /Product_Root/bin scripts for each service startup should be present:
For example :

/Product_Root/bin/Service1.run.cmd
/Product_Root/bin/Service2.run.cmd
...
/Product_Root/bin/ServiceN.run.cmd
...

Script file structure is:

service.exe ../<%SERVICE_NAME%>/conf/service.properties

All values (like <%SERVICE_NAME%>,<%PORT%> etc.) are set by user during setup process for each Service.
Amount of services is also set by user and may vary between 1 (by default) and 20-30.

In case of single service - there is no problem.

Files being copied, directories created using

[Files]
Source: {#FilesPath}\bin\*.*; DestDir: {app}\{#FileLocationPrefix}\bin; Flags: ignoreversion restartreplace
Source: {#АilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}\{code:GetServiceName}\conf; Flags: ignoreversion recursesubdirs createallsubdirs restartreplace; 

[Dirs]
Name: {app}\{#FileLocationPrefix}{code:GetServiceName}\conf

After in ssPostInstall step wildcards replace performed in copied files.

Question.

is it possible using Inno Setup + ISTool to do the same in case of number of services?

E.g. something like that :

[Files]
#for (i = 0; i < ServiceCount(); ++i) 
Source: {#АilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}\{code:GetServiceName| i}\conf; Flags: ignoreversion recursesubdirs createallsubdirs

where i — is actually configuration number.
I.e. is it possible to use information received from user during installation process in [File], [Dirs] etc. sections for multiple copying of the same files in different directories?
For copying single file in number of files with different names set by user during install process?

Or I just going in the wrong direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风吹 2024-09-23 20:09:30

所以,目前我就是这样做的。欢迎评论。
对于创建和复制所有文件:

#define MaxFEInstances 20
...
#sub CreateConf
Source: {#FilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}{code:GetServiceName|{#counter}}\conf; Flags: ignoreversion recursesubdirs createallsubdirs restartreplace; Check: InstanceSetupRequired({#counter}); Components: main
#endsub
#for {counter = 0; counter < MaxInstances; ++counter} CreateConf
enter code here
...
function InstanceSetupRequired(InstanceNum: Integer): Boolean;
begin
  Result := InstanceNum < Instances;
end;

对于单独的文件,它看起来非常相同。

So, currently I've done this in such way. Comments are welcome.
For creating and copying all files:

#define MaxFEInstances 20
...
#sub CreateConf
Source: {#FilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}{code:GetServiceName|{#counter}}\conf; Flags: ignoreversion recursesubdirs createallsubdirs restartreplace; Check: InstanceSetupRequired({#counter}); Components: main
#endsub
#for {counter = 0; counter < MaxInstances; ++counter} CreateConf
enter code here
...
function InstanceSetupRequired(InstanceNum: Integer): Boolean;
begin
  Result := InstanceNum < Instances;
end;

For separate files it looks pretty same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文