; 清除错误标志
ClearErrors
; 读取环境变量 MyPath,如果环境变量不存在将返回空字符串并标志错误
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MyPatha"
IfErrors ShowMessageBox NextStep
ShowMessageBox:
MessageBox MB_OK|MB_ICONINFORMATION "该环境变量不存在" /SD IDOK
NextStep:
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MyPath" "$0;$INSTDIR\Oracle\bin\"
; 刷新环境变量,需要引用 WinMessages 头文件(!include "WinMessages.nsh")
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"