目标文件夹中的路径附加到旧路径,而不是使用 NSIS 显示新路径
Path in the Destination folder is appending to the old path instead of showing the new path using NSIS
我安装的时候,目标文件夹默认显示路径“C:\Program Files (x86)\DllTesting\”(符合预期)。
enter image description here
然后我尝试将路径更改为“C:\Program Files\AppTest”
但是当我选择上面的路径并点击“确定”后,浏览器显示
“C:\Program Files\AppTest\DllTesting”而不是“C:\Program Files\AppTest”
enter image description here
当我从下面的路径中删除“DllTesting”时,它会正确显示新路径而不附加到旧路径。
安装目录 $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
请帮我如何从浏览更改路径而不附加到以前的路径?
阅读文档中的 InstallDir,您会发现:
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\DllTesting
到
InstallDir "$PROGRAMFILES\DllTesting\"
我安装的时候,目标文件夹默认显示路径“C:\Program Files (x86)\DllTesting\”(符合预期)。
enter image description here
然后我尝试将路径更改为“C:\Program Files\AppTest”
但是当我选择上面的路径并点击“确定”后,浏览器显示 “C:\Program Files\AppTest\DllTesting”而不是“C:\Program Files\AppTest”
enter image description here 当我从下面的路径中删除“DllTesting”时,它会正确显示新路径而不附加到旧路径。
安装目录 $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
请帮我如何从浏览更改路径而不附加到以前的路径?
阅读文档中的 InstallDir,您会发现:
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\DllTesting
到
InstallDir "$PROGRAMFILES\DllTesting\"