NSIS - 将文件安装到预先存在的不确定子文件夹中?
NSIS - Install a file to a pre-existing, uncertain subfolder?
我正在尝试将文件安装到结构如下的预先存在的文件夹中:
$APPDATA/somefolder/(uncertainFolder)
"uncertainFolder" 将是“1.0”或“2.0”。
尽管文件夹名称不同,但相同的文件将安装到 "uncertainFolder"。我怎样才能做到这一点?
提前致谢。
用File
指令安装的文件被提取到SetOutPath
设置的目录中。一旦你知道你想要哪个文件夹,在 运行 时间更改此路径不是问题。
如果可能的文件夹名称在编译时已知,您可以使用 if/or if/else:
!include LogicLib.nsh
${If} ${FileExists} "$InstDir\SomeFolder.0\*.*"
SetOutPath "$InstDir\SomeFolder.0"
${Else}
SetOutPath "$InstDir\SomeFolder.0"
${EndIf}
您还可以在 运行 时枚举文件和文件夹:
FindFirst [=11=] "$InstDir\SomeFolder\*.*"
loop:
StrCmp "" end ; No more files?
StrCmp "." next ; DOS special name
StrCmp ".." next ; DOS special name
IfFileExists "$InstDir\SomeFolder$1\*.*" 0 next ; Skip files
DetailPrint " is a folder in $InstDir\SomeFolder"
SetOutPath "$InstDir\SomeFolder$1"
Goto end ; This stops the search at the first folder it finds
next:
FindNext [=11=]
goto loop
end:
FindClose [=11=]
FileFunc.nsh 中的定位宏建立在 FindFirst/FindNext 之上,如果您喜欢它的语法,也可以使用它...
我正在尝试将文件安装到结构如下的预先存在的文件夹中:
$APPDATA/somefolder/(uncertainFolder)
"uncertainFolder" 将是“1.0”或“2.0”。
尽管文件夹名称不同,但相同的文件将安装到 "uncertainFolder"。我怎样才能做到这一点?
提前致谢。
用File
指令安装的文件被提取到SetOutPath
设置的目录中。一旦你知道你想要哪个文件夹,在 运行 时间更改此路径不是问题。
如果可能的文件夹名称在编译时已知,您可以使用 if/or if/else:
!include LogicLib.nsh
${If} ${FileExists} "$InstDir\SomeFolder.0\*.*"
SetOutPath "$InstDir\SomeFolder.0"
${Else}
SetOutPath "$InstDir\SomeFolder.0"
${EndIf}
您还可以在 运行 时枚举文件和文件夹:
FindFirst [=11=] "$InstDir\SomeFolder\*.*"
loop:
StrCmp "" end ; No more files?
StrCmp "." next ; DOS special name
StrCmp ".." next ; DOS special name
IfFileExists "$InstDir\SomeFolder$1\*.*" 0 next ; Skip files
DetailPrint " is a folder in $InstDir\SomeFolder"
SetOutPath "$InstDir\SomeFolder$1"
Goto end ; This stops the search at the first folder it finds
next:
FindNext [=11=]
goto loop
end:
FindClose [=11=]
FileFunc.nsh 中的定位宏建立在 FindFirst/FindNext 之上,如果您喜欢它的语法,也可以使用它...