NSIS 向path新增應用程式安裝路徑
系統路徑path的登錄檔項
!define PRODUCT_UNINST_ROOT_KEY "HKLM" //HKEY_LOCAL_MACHINE的簡稱
!define PATH_KEY "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" //path對應的HKLM下的登錄檔項
在安裝完成後欄位區新增
Var vPath //新加,自定義變數,用於接受原path中的變數值
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
ReadRegStr $vPath ${PRODUCT_UNINST_ROOT_KEY} "${PATH_KEY}" "Path" //取原值
strcpy $vPath "$vPath+$INSTDIR" //字串連線嘍
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PATH_KEY}" "Path" "$vPath" //寫新值
SectionEnd
結束,謝謝賞光!