Archive: Remove entry from environment path


Remove entry from environment path
Hi there,

in my installation process I am adding
an entry to the environment path.

How can I remove this entry during uninstall?
I need to find a substring within a string and
remove it, but how can I do this in NSIS?

Any ideas?


Have a look at the StrStr function in the function-examples of the NSIS documentation. It does not what you want, but you should be able to modify it to your needs.

Ciao
-Fritz


Thanks for your help. It works.

Here's the solution:

Name "stringtest"
OutFile "stringtest.exe"

;------------------------------------------------------------------------------
; RemoveStr
; input, top of stack = string to search for
; top of stack-1 = string to search in
; output, top of stack (replaces with the portion of the string remaining)
; modifies no other variables.
;
; Usage:
; Push "this is a long ass string"
; Push "ass"
; Call StrStr
; Pop $0
; ($0 at this point is "this is a long string")

Function RemoveStr
Exch $1 ; st=haystack,old$1, $1=needle
Exch ; st=old$1,haystack
Exch $2 ; st=old$1,old$2, $2=haystack
Push $3
Push $4
Push $5
StrLen $3 $1
StrCpy $4 0
; $1=needle
; $2=haystack
; $3=len(needle)
; $4=cnt
; $5=tmp
; $6= output string with search string removed
; $7= tmp output character
loop:
StrCpy $5 $2 $3 $4
StrCmp $5 $1 skip
StrCmp $5 "" done

;-- Copy current character into output if no match was detected and increment counter
StrCpy $7 $2 1 $4
StrCpy $6 "$6$7"
IntOp $4 $4 + 1
Goto loop

;-- Inrement by length of hayneedle
skip:
IntOp $4 $4 + $3
Goto loop

done:
StrCpy $1 $2 "" $4
Pop $5
Pop $4
Pop $3
Pop $2
Exch $6
FunctionEnd


;--------------------------------------------------
;- Test Function
;--------------------------------------------------

Section "" ; (default section)

Push "laberschwallblalaberschwallblalaberschwallblalaberschwallblalaberschwallblalaberschwallbla"
Push "schwall"

Call RemoveStr

Pop $0

MessageBox MB_OK $0

SectionEnd


Hi!

I have once made some functions that do exacly what you are looking for. I have also made a little program that will allow you to update enviorment variables without reboooting under NT.

http://forums.winamp.com/showthread....threadid=67208