简体   繁体   English

如何使用Inno Setup Compiler在exe文件中包含一个文件夹

[英]How to include a folder in your exe file using Inno Setup Compiler

I'm currently using Inno Setup Compiler to create an installer for Windows and everything is working fine except when I try to include a folder to the exe. 我目前正在使用Inno Setup Compiler为Windows创建一个安装程序,除非我尝试在exe文件中包含一个文件夹,否则一切正常。 In other words what I want is to be able to include a folder with two files in it, I want this folder to appear right where the .exe file is (C:\\Program Files x86\\appFolder) when the program is installed. 换句话说,我想要的是能够包含一个包含两个文件的文件夹,我希望这个文件夹在安装程序时出现在.exe文件所在的位置(C:\\ Program Files x86 \\ appFolder)。

Inno has an option to add folders but for some reason when I select the folder with the two files I want, it compiles fine but when I actually install the program it actually adds the two files but not the folder. Inno有一个添加文件夹的选项,但出于某种原因,当我选择包含我想要的两个文件的文件夹时,它编译得很好但是当我实际安装程序时它实际上添加了两个文件而不是文件夹。

I found the following line of code online and I used it but it actually included some folders that I didn't want. 我在网上发现了以下代码行,我使用它但实际上包含了一些我不想要的文件夹。 The problem I have with this line of code is that I don't fully understand it, I don't know where the folder path should be? 我对这行代码的问题是我不完全理解它,我不知道文件夹路径应该在哪里? What is Exlude: "Setup.iss,generated_images\\" 什么是Exlude:“Setup.iss,generated_images \\”

Source: "*.*"; Excludes: "Setup.iss,generated_images\*"; DestDir: "{app}"; Flags:replacesameversion recursesubdirs

Can someone be so kind an explain this line of code? 有人可以解释这行代码吗?

Thanks 谢谢

From your comments (as you haven;t actually shown all the code you're talking about), I guess you are doing something like: 根据你的评论(因为你没有;实际上显示了你正在谈论的所有代码),我猜你做的是:

[Files]
Source: "blah.exe"; DestDir: "{app}"; Flags:replacesameversion
Source: "subfolder\*.*"; DestDir: "{app}"; Flags:replacesameversion

In this case, it is copying the contents of subfolder to {app} . 在这种情况下,它将subfolder的内容复制到{app}

If you want to copy it and keep the sub directory, specify the directory itself: 如果要复制它并保留子目录,请指定目录本身:

[Files]
Source: "blah.exe"; DestDir: "{app}"; Flags: replacesameversion
Source: "subfolder"; DestDir: "{app}"; Flags: replacesameversion recursesubdirs

Or specify an explicit destination directory: 或指定显式目标目录:

[Files]
Source: "blah.exe"; DestDir: "{app}"; Flags:replacesameversion
Source: "subfolder\*.*"; DestDir: "{app}\subfolder"; Flags:replacesameversion

I was having a similar problem: 我遇到了类似的问题:

I have this folder among other things: 我有这个文件夹和其他东西:

  • .\\WorkFolder\\MyEmptyFolder\\ \\ WorkFolder \\ MyEmptyFolder \\

I want on installed system this: 我想在已安装的系统上这样:

  • .\\PathToExe\\Name.exe \\ PathToExe \\ Name.exe
  • .\\PathToExe\\MyEmptyFolder\\ \\ PathToExe \\ MyEmptyFolder \\

If folder is not empty it works, but sometimes i need empty folder. 如果文件夹不为空它可以工作,但有时我需要空文件夹。

I am using this line: 我正在使用这一行:

Source: .\WorkFolder\MyEmptyFolder\*; DestDir: {app}\MyEmptyFolder; Flags: ignoreversion recursesubdirs createallsubdirs

What i want script to do is (without need to re-write the script every time): 我希望脚本做的是(每次都不需要重写脚本):

  • If folder is empty, then on installed the folder will be empty but exists 如果文件夹为空,则在安装时该文件夹将为空但存在
  • If folder has files and/or subfolders, then on installed the folder will exists and have that content 如果文件夹包含文件和/或子文件夹,则在安装时该文件夹将存在并具有该内容

My problem is when it is empty, script ends with an error telling there is no files on it. 我的问题是当它为空时,脚本以错误告知其上没有文件结束。 It does not understand i want that folder and all what on it could be at that moment. 它不明白我想要那个文件夹以及当时的所有内容。

Thanks for the ideas, i try them and got the solution, here it is: 感谢您的想法,我尝试了解并获得了解决方案,这里是:

First ensure the folder will be created (if has no files with Files section it does not create it): 首先确保将创建文件夹(如果没有带文件的文件部分,则不创建它):

[Dirs]
Name: {app}\; Permissions: users-modify
Name: {group}\; Permissions: users-modify
Name: {app}\MyEmptyFolder\; Permissions: users-modify

Next edit the line on Files section to include "skipifsourcedoesntexist": 接下来编辑“文件”部分中的行以包含“skipifsourcedoesntexist”:

Source: .\WorkFolder\MyEmptyFolder\*; DestDir: {app}\MyEmptyFolder; Flags: ignoreversion recursesubdirs createallsubdirs skipifsourcedoesntexist

And it does what i want: Include such folder and all what is on it, no matter if folder is empty or not, script will not end with an error if it is empty. 它做我想要的:包括这样的文件夹和所有内容,无论文件夹是否为空,如果它是空的,脚本不会以错误结束。

How this works? 这是怎么回事?

Easy trick: if folder is empty, file section line would fail and script will end with an error, but with skipifsourcedoesntexist it avoid that, but that would make such folder not exist, that is the reason why i add such folder on Dirs section, to ensure it is allways created. 简单的技巧:如果文件夹为空,文件部分行将失败并且脚本将以错误结束,但是使用skipifsourcedoesntexist它会避免这种情况,但这会使这样的文件夹不存在,这就是我在Dirs部分添加这样的文件夹的原因,确保它始终是创造的。

Hope this helps other not getting mad ! 希望这有助于其他人不要生气!

在制作安装文件Inno SETUP时....单击新文件夹,单击该URL,然后单击编辑并命名要包含在安装文件夹中的子文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM