Archive: Help removing enviro paths


Help removing enviro paths
I'm currently using the following to add paths to the system path:


${registry::Read} "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" "Path" $R1 $R2
StrCpy $R1 "$R1;$INSTDIR\php"
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1"


In the uninstaller portion, I'm not sure exactly how to remove that chunk of text ($INSTDIR\php) since I don't see a find/replace/remove string function. How does one accomplish this?

http://nsis.sourceforge.net/Path_Manipulation

or

Name "MyProgram"
OutFile "MyProgram.exe"

!include "WordFunc.nsh"
!insertmacro WordFind
!insertmacro un.WordReplace

InstallDir "$PROGRAMFILES\MyProgram"
Page directory
Page instfiles

Section Install
ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
${WordFind} "$R1" "$INSTDIR\php" "E+1{" $R0
IfErrors 0 end
StrCpy $R1 "$R1;$INSTDIR\php"
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram" "phpEnvPath" "$INSTDIR\php"

end:
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd

Section un.Install
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram" "phpEnvPath"
ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
${un.WordReplace} "$R1" ";$R0" "" "+" $R1
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram"

SetOutPath "$TEMP"
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
SectionEnd

Thanks that works great