1、下载插件https://nsis.sourceforge.io/EnVar_plug-in
2、解压到 '$PROGRAMFILES\NSIS'
3、加入环境变量
; Set to HKLMEnVar::SetHKLM; Add an expanded valueEnVar::AddValue "Path" "$INSTDIR"Pop $0DetailPrint "EnVar::AddValue returned=|$0|"
4、删除环境变量
; Set to HKLMEnVar::SetHKLMEnVar::DeleteValue "Path" "$INSTDIR"Pop $0DetailPrint "EnVar::DeleteValue returned=|$0|"