在安装时,默认情况下,在“目标文件夹”中显示路径“ C:\ Program Files(x86)\ DllTesting \”(这与预期的一样)。
然后我尝试将路径更改为“ C:\ Program Files \ AppTest”
但是从浏览器中选择了上面的路径并单击“确定”后,它将显示 “ C:\ Program Files \ AppTest \ DllTesting”,而不是“ C:\ Program Files \ AppTest”
enter image description here 当我从以下路径中删除“ DllTesting”时,它正确显示了新路径,而没有追加到旧路径。
InstallDir $ PROGRAMFILES \ DllTesting
但是我无法从上述路径中删除“ DllTesting”,因为默认情况下,我应该显示该路径 “ C:\ Program Files(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
请帮助我如何从浏览更改路径而不附加到上一个路径?
答案 0 :(得分:0)
在文档中阅读有关InstallDir的信息,您将找到:
请注意,如果用户选择“浏览”,则会使用该字符串中最后一个\之后的部分,并且可能会在安装时附加在该字符串后面(为此,请在目录末尾加上
\
(这将要求整个参数都用引号引起来)。
尝试更改
InstallDir $PROGRAMFILES\DllTesting
到
InstallDir "$PROGRAMFILES\DllTesting\"