【NSIS使用经验】修改和删除环境变量

;设置oracle的环境变量到PATH路径
ReadRegStr $0 HKLM “SYSTEM\CurrentControlSet\Control\Session Manager\Environment” “Path”
WriteRegExpandStr HKLM “SYSTEM\CurrentControlSet\Control\Session Manager\Environment” “Path” “$0;$INSTDIR\Oracle\bin\”
;刷新环境变量
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 “STR:Environment”

;利用WordReplace函数从PATH中删除设置oracle的环境变量
;需要在文件头引入相应的头文件:!include “WordFunc.nsh”
ReadRegStr $R0 HKLM “SYSTEM\CurrentControlSet\Control\Session Manager\Environment” “Path”
${WordReplace} $R0 “;$INSTDIR\Oracle\bin\” “” “+” $R1
;MessageBox MB_OK|MB_USERICON ‘$R0 – $INSTDIR – $R1 ‘
WriteRegExpandStr HKLM “SYSTEM\CurrentControlSet\Control\Session Manager\Environment” “Path” “$R1″

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>