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".
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 PROD开发者_运维问答UCT_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
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).
So you probably want Installdir "$programfiles\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}\"
精彩评论