- NSIS Discussion
- Help needed
Archive: Help needed
blazer1504
4th May 2003 09:47 UTC
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 ?
Yathosho
4th May 2003 10:59 UTC
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
Afrow UK
4th May 2003 14:10 UTC
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
Joel
4th May 2003 16:41 UTC
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
Joost Verburg
5th May 2003 14:13 UTC
You can detect it using a function, so that won't be addded (it will increase the overhead).
blazer1504
6th May 2003 10:23 UTC
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 ?
Joost Verburg
6th May 2003 12:36 UTC
StrCpy supports negative values for the lenght (so you can cut off chars).
blazer1504
7th May 2003 10:11 UTC
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?
Joost Verburg
7th May 2003 10:31 UTC
Use start_offset, not maxlen.
blazer1504
8th May 2003 09:55 UTC
um....
/me is confused. me don't understand
Please give me example how it works, and maybe I'll figure it out then..:rolleyes:
Sunjammer
8th May 2003 10:34 UTC
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.
blazer1504
8th May 2003 11:30 UTC
That makes sense, thanks man , I really appreciate :)
pengyou
8th May 2003 16:04 UTC
Try this to copy all characters from position 13:
StrCpy $2 $1 "" 13
blazer1504
8th May 2003 19:49 UTC
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 ;)
pengyou
8th May 2003 20:35 UTC
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.
Afrow UK
8th May 2003 20:58 UTC
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
blazer1504
9th May 2003 13:56 UTC
ok, now it works perfect !
Thanks again guys ! :)