Archive: Help needed


Help needed
I'm having little trouble with my install script and I'm wishing that maybe some of you guys could help me with this:

Okay, what I'm trying to do here is to detect winamp2 to $1 and Winamp3 to $2

ReadRegStr $1 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"

ReadRegStr $2 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp3" \
"UninstallString"

These sets wa2 (if exists) to $1 & wa3 (if exists) to $2, right.
because we get the path in file format (...\winamp(3)\uninstall.exe) I need to get that file stripped, and here's where I have problems.

With what function I could erase the letter from both, $1 & $2, one by one until the last letter would be different ?

Or with what function, I could erase letter from both , $1 & $2, one by one until the first ' \ ' mark comes ?


hey,

there's a script in the avs forum, just have a look at the StripPath Function from EL-VIS. i can also offer you my avscript (version 3 out soon), will talk to you on #finnish-flash about that :D


Use GetFileName here:
http://nsis.sourceforge.net/archive/...ances=0,11,211

That will get the uninstall.exe part, whether it is uninstall.exe or not.

-Stu


I'll be cool as feature to create variables to detect Winamp 2
and Winamp 3.
For example:
$INSTDIR means the installation directory, right?
So


$WINAMP2 'will be the path for Winamp 2.x installation
$WINAMP3 'will be the path for Winamp 3.x installation

You can detect it using a function, so that won't be addded (it will increase the overhead).


there's a script in the avs forum, just have a look at the StripPath Function from EL-VIS. i can also offer you my avscript (version 3 out soon), will talk to you on #finnish-flash about that
The el-vis is little oldish since it's designed for Nsis1 and I couldn't get that Jheriko's script work with me (maybe I have too old version of NSIS2) and besides I like to do things by myself, so..

It's still not clear to me how the stripping does work, with what function I can erase for example 9 last letters from the path ?

StrCpy supports negative values for the lenght (so you can cut off chars).


okay let's imagine that $1 would point to C:/something/word.exe
Let's say that I'd like to get the file out and copy it to $2, would this work?

StrCpy $2 $1 -8

or is it more complicate than that?


Use start_offset, not maxlen.


um....

/me is confused. me don't understand

Please give me example how it works, and maybe I'll figure it out then..:rolleyes:


What Joost is saying relates to the documentation for StrCpy. The syntax is

user_var(destination) str [maxlen] [start_offset]
so he is saying you need to make use of the start_offset parameter and not the maxlen parameter. This is because in your example rather than getting the file you'd actually get the path, e.g. 'C:/something/' instead of 'word.exe'.

You need to do :-
StrLen $3 $1 ; how long is our string?
IntOp $4 $3 - 8 ; where do we start copying?
StrCpy $2 $1 $3 $4 ; copy $3 amount of characters from position $4 in string $1 into string $2

One thing I realised working this out is that you can't do this :-
StrCpy $2 $1 0 13
i.e. I was trying to say copy all characters from position 13, bit of a shame that.

That makes sense, thanks man , I really appreciate :)


Try this to copy all characters from position 13:


StrCpy $2 $1 "" 13

Function stripwa2
StrLen $3 $1
IntOp $4 $3 - 13
StrCpy $2 $1 $3 $4
functionEnd

I tried this like you told (used $2 in SetOutPath) but it gave me the file ( uninst.exe\plugins\blahblah ) that's what I wanted to cut off from the path :rolleyes:

I'm sure, you can easily change that by changing some positions of $1-$4 but after trying to figure it out long enough, I thought to leave it to you smarter guys ;)


If I understand the problem correctly, the uninstall string from the registry for Winamp2 looks like this:

"x:\blah blah blah\winamp.exe" /UNINSTALL


and you want to extract just the
x:\blah blah blah\
part of the string.

One way to do this is to cut off the last 22 characters and cut off the first character ("), as follows:


; $1 holds "x:\blah blah blah\winamp.exe" /UNINSTALL
; Now cut off the last 22 characters (i.e. cut off winamp.exe" /UNINSTALL)

StrCpy $1 $1 -22

; Now $1 = "x:\blah blah blah\

StrCpy $1 $1 "" 1

; Now $1 = x:\blah blah blah\


If the Winamp3 uninstall string is "x:\blah blah blah\winamp3.exe" /UNINSTALL then you have to cut off 23 characters instead of 22.

Hope this helps.

I see that there are no "\" characters until you reach "x:\blah blah blah\" in the string.
You can therefore use the GetParent function (on the NSIS Archive) and then use my GetFileName function after that.

-Stu


ok, now it works perfect !

Thanks again guys ! :)