update script

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@468748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
aheritier 2006-10-28 21:46:04 +00:00
parent 5536e283f9
commit df939be1f0

View File

@ -1,15 +1,17 @@
;
; From NSISArchives http://nsis.sourceforge.net/archive/nsisweb.php?page=156&instances=0,11
;
!ifndef _WriteEnvStr_nsh
!define _WriteEnvStr_nsh
!include WinMessages.nsh
!ifdef ALL_USERS
!define WriteEnvStr_RegKey \
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!else
!define WriteEnvStr_RegKey 'HKCU "Environment"'
!ifndef WriteEnvStr_RegKey
!ifdef ALL_USERS
!define WriteEnvStr_RegKey \
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!else
!define WriteEnvStr_RegKey 'HKCU "Environment"'
!endif
!endif
#
# WriteEnvStr - Writes an environment variable
# Note: Win9x systems requires reboot
@ -24,7 +26,7 @@ Function WriteEnvStr
Exch
Exch $0 ; $0 has environment variable name
Push $2
Call IsNT
Pop $2
StrCmp $2 1 WriteEnvStr_NT
@ -36,18 +38,18 @@ Function WriteEnvStr
FileClose $2
SetRebootFlag true
Goto WriteEnvStr_done
WriteEnvStr_NT:
WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $1
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
0 "STR:Environment" /TIMEOUT=5000
WriteEnvStr_done:
Pop $2
Pop $1
Pop $0
Pop $1
FunctionEnd
#
# un.DeleteEnvStr - Removes an environment variable
# Note: Win9x systems requires reboot
@ -63,7 +65,7 @@ Function un.DeleteEnvStr
Push $3
Push $4
Push $5
Call un.IsNT
Pop $1
StrCmp $1 1 DeleteEnvStr_NT
@ -74,7 +76,7 @@ Function un.DeleteEnvStr
FileOpen $2 $4 w
StrCpy $0 "SET $0="
SetRebootFlag true
DeleteEnvStr_dosLoop:
FileRead $1 $3
StrLen $5 $0
@ -83,7 +85,7 @@ Function un.DeleteEnvStr
StrCmp $5 "" DeleteEnvStr_dosLoopEnd
FileWrite $2 $3
Goto DeleteEnvStr_dosLoop
DeleteEnvStr_dosLoopEnd:
FileClose $2
FileClose $1
@ -92,12 +94,12 @@ Function un.DeleteEnvStr
CopyFiles /SILENT $4 "$1\autoexec.bat"
Delete $4
Goto DeleteEnvStr_done
DeleteEnvStr_NT:
DeleteRegValue ${WriteEnvStr_RegKey} $0
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
0 "STR:Environment" /TIMEOUT=5000
DeleteEnvStr_done:
Pop $5
Pop $4
@ -106,7 +108,10 @@ Function un.DeleteEnvStr
Pop $1
Pop $0
FunctionEnd
!ifndef IsNT_KiCHiK
!define IsNT_KiCHiK
#
# [un.]IsNT - Pushes 1 if running on NT, 0 if not
#
@ -128,7 +133,7 @@ Function ${UN}IsNT
Pop $0
Push 0
Return
IsNT_yes:
; NT!!!
Pop $0
@ -137,3 +142,8 @@ FunctionEnd
!macroend
!insertmacro IsNT ""
!insertmacro IsNT "un."
!endif ; IsNT_KiCHiK
!endif ; _WriteEnvStr_nsh