简体   繁体   English

NSIS - 如何使用单个命令安装具有相似文件夹结构的多个文件?

[英]NSIS - How to install multiple files with similar folder structures using a single command?

Problem问题

I have multiple files in very similarly structured folders that I want to install in one common folder.我在结构非常相似的文件夹中有多个文件,我想将它们安装在一个公共文件夹中。

I can do this by manually specifying each file I want to add, like so:我可以通过手动指定要添加的每个文件来做到这一点,如下所示:

SetOutPath "$INSTDIR\Final\Destination"
File /r ".\ParentFolder\Folder1\Same\Path\For\All\Thing1.ext"
File /r ".\ParentFolder\Folder2\Same\Path\For\All\Thing2.ext"
File /r ".\ParentFolder\Folder3\Same\Path\For\All\Thing3.ext"
File /r ".\ParentFolder\Folder4\Same\Path\For\All\Thing4.ext"
File /r ".\ParentFolder\Folder5\Same\Path\For\All\Thing5.ext"

However, there are 50+ of these files, and they are likely to change, so I'd prefer to do this in a way that won't require editing the NSIS in the future.但是,这些文件有 50 多个,而且它们很可能会更改,所以我更愿意以一种将来不需要编辑 NSIS 的方式来执行此操作。

What I have Tried我试过的

I tried putting in wildcards, like so:我尝试放入通配符,如下所示:

SetOutPath "$INSTDIR\Final\Destination"
File /r ".\ParentFolder\*\Same\Path\For\All\*.ext"

However, I get the message File: ".\ParentFolder\*\Same\Path\For\All\*.ext" -> no files found.但是,我收到消息File: ".\ParentFolder\*\Same\Path\For\All\*.ext" -> no files found.

Question

Is there something wrong with using multiple wildcards * in my File query?在我的File查询中使用多个通配符*有什么问题吗?

What would be the correct way to query multiple files in different folders?查询不同文件夹中的多个文件的正确方法是什么?

You can't put wildcards anywhere, only in the filename unfortunately.不幸的是,您不能在任何地方放置通配符,只能在文件名中放置。

What you can do however is to use !system to execute a batch file (or any other command or application) that writes NSIS instructions to a file you can !include :然而,你可以做的是使用!system来执行一个批处理文件(或任何其他命令或应用程序),将 NSIS 指令写入一个文件,你可以!include

Section

SetOutPath $InstDir
!tempfile folders ; temporary .nsh
!system 'for /D %A in (.\ParentFolder\*) do @>>"${folders}" echo File /r "%~A\Same\Path\For\All\*.ext"'
!include "${folders}"
!delfile "${folders}"

SectionEnd

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

相关问题 使用 NSIS 安装在 ProgramData 文件夹中 - install in ProgramData folder using NSIS 使用 NSIS zip 文件夹安装特定的依赖项 - Install a specific dependency using NSIS zip folder 如何使用本地文件夹中的NSIS脚本添加新页面以创建安装程序,而不是从程序文件/ NSIS中获取它 - How to add the new page using NSIS script in the local folder to create the installer instead of taking it from program files /NSIS 使用NSIS安装程序,通过右键单击Windows菜单,为多个选定文件运行单个软件实例 - Running a single instance of software for multiple selected files by right click menu of windows using NSIS installer 如何在具有提升的UAC的Windows操作系统上使用NSIS将dll复制并安装到Assembly文件夹中 - How to copy and install a dll into assembly folder using NSIS on an Windows OS with elevated UAC 如何使用NSIS安装字体? - How do I install a font using NSIS? 更改NSIS中的默认安装文件夹 - Change the default install folder in NSIS 无提示NSIS安装后如何返回命令提示符 - How to return to command prompt after a silent NSIS install 使用NSIS将应用程序文件安装到标准Windows用户 - Install application files to standard windows user using NSIS 如何使用 NSIS 对文件进行签名? - How can I sign the files using NSIS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM