[英]!define MUI_PAGE_DIRECTORY_VARIABLE does not create variable - NSIS
I'm trying to create an NSIS script which copies various files to two different locations that can be specified. 我正在尝试创建一个NSIS脚本,该脚本将各种文件复制到可以指定的两个不同位置。 I have checked the documentation and other StackOverflow entries but do not come up with a solution.
我已经检查了文档和其他StackOverflow条目,但没有提出解决方案。 My Problem is that I want to define a second variable for a directory.
我的问题是我想为目录定义第二个变量。 In this directory sample files and projects shall be copied.
在此目录中,应复制示例文件和项目。
When trying to compile the NSI I get the following error/warnings: 尝试编译NSI时,出现以下错误/警告:
3 warnings:
unknown variable/constant "APPDIR" detected, ignoring (C:\Users\max\Desktop\PortablePlayer\so.nsi:29)
unknown variable/constant "APPDIR" detected, ignoring (C:\Users\max\Desktop\PortablePlayer\so.nsi:33)
unknown variable/constant "APPDIR\Testfile.txt" detected, ignoring (C:\Users\max\Desktop\PortablePlayer\so.nsi:43)
Here is my script that I'm using: 这是我正在使用的脚本:
!include "MUI.nsh"
Name "MyApp"
OutFile "MyApp-Installer.exe"
InstallDir "$PROGRAMFILES\My App"
; Installation Directory for the App
!insertmacro MUI_PAGE_DIRECTORY
; Installation Directory for the samples and projects
!define MUI_PAGE_HEADER_SUBTEXT "Choose your custom Samples Folder"
!define MUI_DIRECTORYPAGE_TEXT_TOP "To separate your App and your samples and projects you can choose a different folder than the installation directory"
!define MUI_PAGE_DIRECTORY_VARIABLE $APPDIR
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section ""
SetOutPath $INSTDIR
File Testfile.txt
SetOutPath $APPDIR
File Testfile.txt
FileOpen $0 "$DESKTOP\Hello_world.txt" w
FileWrite $0 $APPDIR
FileClose $0
WriteUninstaller "$INSTDIR\MyApp-Uninstaller.exe"
SectionEnd
Section "Uninstall"
Delete "$INSTDIR\Testfile.txt"
Delete "$INSTDIR\MyApp-Uninstaller.exe"
RMDir $INSTDIR
Delete "$APPDIR\Testfile.txt"
SectionEnd
For debugging I tried to write the value of $APPDIR into a textfile but it only writes $APPDIR instead of the value. 为了进行调试,我尝试将$ APPDIR的值写入文本文件,但只写入$ APPDIR而不是值。 If I change it to $INSTDIR it prints the correct path for $INSTDIR.
如果将其更改为$ INSTDIR,它将为$ INSTDIR打印正确的路径。 How can I initialize the variable for $APPDIR?
如何初始化$ APPDIR的变量? If I try to initialize it on the top, it is there but empty, so the installer fails after succesful compilation of the script.
如果我尝试在顶部对其进行初始化,则该位置在那里但为空,因此在脚本成功编译后安装程序将失败。
Running Win 7 with NSIS 2.5.1 使用NSIS 2.5.1运行Win 7
Can anybody please shed some light on what is wrong? 有人可以告诉我们哪里出了问题吗?
Thanks! 谢谢!
The MUI_DIRECTORYPAGE_VARIABLE
define tells MUI that you have a custom variable that you want to use but MUI does not create the variable, you have to do that yourself near the top of your script: MUI_DIRECTORYPAGE_VARIABLE
定义告诉MUI您有要使用的自定义变量,但MUI不会创建该变量,您必须在脚本顶部附近自己做:
Var APPDIR
So it should look something like 所以它看起来应该像
Var APPDIR
!include "MUI.nsh"
!define MUI_DIRECTORYPAGE_VARIABLE $APPDIR
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section
DetailPrint $APPDIR
SectionEnd
Edit: The name of the define is MUI_DIRECTORYPAGE_VARIABLE not MUI_PAGE_DIRECTORY_VARIABLE like you have in your example... 编辑:定义的名称是MUI_DIRECTORYPAGE_VARIABLE而不是MUI_PAGE_DIRECTORY_VARIABLE像您在示例中一样...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.