目标文件夹中的路径将附加到旧路径,而不是使用NSIS显示新路径

目标文件夹中的路径将附加到旧路径,而不是使用NSIS显示新路径,nsis,Nsis,安装时,默认情况下,目标文件夹中显示路径“C:\Program Files(x86)\DllTesting\”(如预期) 然后我尝试将路径更改为“C:\Program Files\AppTest” 但在浏览中,一旦我选择了上面的路径并点击“OK”,它就会显示出来 “C:\Program Files\AppTest\DllTest”而不是“C:\Program Files\AppTest” 当我从下面的路径中删除“DllTesting”时,它将正确显示新路径,而不附加到旧路径 InstallD

安装时,默认情况下,目标文件夹中显示路径“C:\Program Files(x86)\DllTesting\”(如预期)

然后我尝试将路径更改为“C:\Program Files\AppTest”

但在浏览中,一旦我选择了上面的路径并点击“OK”,它就会显示出来 “C:\Program Files\AppTest\DllTest”而不是“C:\Program Files\AppTest”

当我从下面的路径中删除“DllTesting”时,它将正确显示新路径,而不附加到旧路径

InstallDir$PROGRAMFILES\DllTesting

但是我不能从上面的路径中删除“DllTesting”,因为默认情况下我应该显示路径 “C:\ProgramFiles(x86)\DllTesting\”

下面是我的代码片段:

; DllTesting.nsi
;
;--------------------------------
!include LogicLib.nsh

Name "DllTesting"
OutFile "DllTesting.exe"

InstallDir $PROGRAMFILES\DllTesting

InstallDirRegKey HKLM "Software\NSIS_DllTesting" "Install_Dir"

RequestExecutionLevel admin

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "DllTesting (required)"

  SetOutPath $INSTDIR
  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\NSIS_DllTesting "Install_Dir" "$INSTDIR"

  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DllTesting" "DisplayName" "NSIS DllTesting"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DllTesting" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DllTesting" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DllTesting" "NoRepair" 1
  WriteUninstaller "uninstall.exe"

SectionEnd

请帮助我如何从“浏览”更改路径而不附加到以前的路径?

阅读文档中有关InstallDir的内容,您会发现:

请注意,如果用户选择“浏览”,则将使用最后一个\后面的字符串部分,并且可以在安装时将追加回字符串(要禁用此功能,请使用
\
结束目录(这将要求用引号括起整个参数)

试着改变

InstallDir $PROGRAMFILES\DllTesting


请勿破坏您的帖子。通过在此网站上发布,您已不可撤销地授予Stack Exchange network在其认为合适的时间内根据分发该内容的权利。有关删除的替代方法,请参阅:
InstallDir "$PROGRAMFILES\DllTesting\"