Windows installer 如何在NSIS脚本中添加文件选择输入?
我正在使用NSIS创建windows安装程序。在这个安装程序中,我想在一个页面上请求用户使用许可文件输入添加许可文件。如果许可证文件有效,则用户将能够继续,否则将抛出错误消息。但在构建本身的创建过程中,我遇到了一个错误。请参考我的以下代码和错误:Windows installer 如何在NSIS脚本中添加文件选择输入?,windows-installer,nsis,Windows Installer,Nsis,我正在使用NSIS创建windows安装程序。在这个安装程序中,我想在一个页面上请求用户使用许可文件输入添加许可文件。如果许可证文件有效,则用户将能够继续,否则将抛出错误消息。但在构建本身的创建过程中,我遇到了一个错误。请参考我的以下代码和错误: Function LicenseWarning !insertmacro MUI_HEADER_TEXT "License Warning" "" nsDialogs::Create 1018
Function LicenseWarning
!insertmacro MUI_HEADER_TEXT "License Warning" ""
nsDialogs::Create 1018
Pop $LicenseWarningDialog
${If} $LicenseWarningDialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 20u "This version of QMF Vision requires license for activation. Ensure you have the license file available or contact your administrator."
Pop $LicenseWarningMsg
${NSD_CreateGroupBox} 2u 70u 295u 38u "Select License File"
${NSD_CreateFileRequest} 10u 85u 210u 12u ""
Pop $LicenseFileInput
${NSD_CreateBrowseButton} 228u 83u 55u 14u "Browse..."
Pop $BrowseButton
${NSD_OnClick} $BrowseButton OnBrowseForLicense
${NSD_SetText} $LicenseFileInput $LicenseFile
nsDialogs::Show
FunctionEnd
Function OnBrowseForLicense
nsDialogs::SelectFileDialog open "" "*.lic"
Pop $0
${If} $0 != ""
${GetFileName} $0 $1
${If} $1 == "license.lic"
StrCpy $LicenseFile $0
${NSD_SetText} $LicenseFileInput $0
SetOutPath $INSTDIR\data
IfFileExists $LicenseFile 0 file_not_found
File $LicenseFile <= On this line I am getting an error
file_not_found:
${Else}
MessageBox MB_ICONINFORMATION|MB_OK "License file is invalid."
Abort
${EndIf}
${EndIf}
FunctionEnd
请帮我解决它。提前感谢。文件指令用于将文件压缩到安装程序中,并且只能在编译安装程序的机器上使用 使用和
FileRead
解析用户系统上的文件。如果要将所选文件复制到安装目录,请使用CopyFiles/silent/filesonly$LicenseFile$InstDir
在应用程序中检查许可证而不是安装程序可能是一个更好的主意…我想在安装目录中添加许可证文件,因为它就像HTML中的文件上载输入一样。我已经尝试了硬编码文件,代码运行良好。检查位于的“简单安装文件”代码。您不能在自定义页面上向安装程序添加文件。您可以将文件从a复制到B。是的,我想从a复制到B。但在这种情况下,B位置将在安装程序脚本中定义为$INSTDIR\data,用户将在通过${NSD_CreateFileRequest}安装时添加一个位置。这不是问题。请参阅我答案的编辑。
File: "$LicenseFile" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)