浏览安装目录"$ {PRODUCT_NAME}"后的NSIS目录页面;选择后添加 [英] NSIS Directory Page after Browse for install dir "${PRODUCT_NAME}" is added after selection

查看:42
本文介绍了浏览安装目录"$ {PRODUCT_NAME}"后的NSIS目录页面;选择后添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有目录页面的简单NSIS脚本,用户可以在其中选择一个目录来将应用程序安装到该目录.请参阅下面的示例,如果已经安装了该应用程序,它将从注册表中获取值,或者从www根目录中获取值,或者从程序文件\发布者\产品名称"中获取值.

I have a simple NSIS script with a directory page, where the user can select a directory to install the application to. See the example below, if the app is already installed, it takes the value from the registry or else the www root or else "program files\publisher\product name".

问题在于,当我单击目录页面上的浏览并选择特定目录(例如:c:\ test)时,当我关闭浏览对话框时,定义PRODUCT_NAME将自动添加到以下路径:c:\ test \发票管理工作流程.如何避免产品名称自动添加"?

The problem is that when I click browse on the directory page and select a specific directory (e.g: c:\test), when I close the browse dialog the define PRODUCT_NAME is automatically added to the path: c:\test\Invoice Management Workflow. How can I avoid the product name being added automatically"?

!define PRODUCT_NAME "Invoice Management Workflow"

!insertmacro MUI_DEFINES
!insertmacro MUI_PAGE_WELCOME
Page directory DirPre
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES

Function DirPre
    ; set the INSTDIR to 
    ReadRegStr $0 HKLM "Software\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}" "InstallDirectory"
    ${If} $0 != ""
        StrCpy $INSTDIR $0
        Abort
    ${Else}
        ; get the install dir from reg
        ReadRegStr $0 HKLM "SOFTWARE\Microsoft\InetStp" "PathWWWRoot"
        ${If} $0 != ""
            StrCpy $INSTDIR $0
        ${EndIf}
    ${EndIf}
FunctionEnd

推荐答案

这与InstallDir指令相关,引用于手册:

This is related to the InstallDir instruction, to quote from the manual:

请注意,此字符串的一部分如果最后一个\之后,将使用用户选择浏览",并且可能是附加回字符串在安装时间(要禁用此功能,请结束带有\的目录(这将要求包含的整个参数带有引号).

Note that the part of this string following the last \ will be used if the user selects 'browse', and may be appended back on to the string at install time (to disable this, end the directory with a \ (which will require the entire parameter to be enclosed with quotes).

所以您可能需要 Installdir"$ programfiles \ $ {PRODUCT_PUBLISHER} \ $ {PRODUCT_NAME} \"

这篇关于浏览安装目录"$ {PRODUCT_NAME}"后的NSIS目录页面;选择后添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆