![]() |
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 code: |
You can detect it using a function, so that won't be addded (it will increase the overhead).
|
Quote:
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
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'.code: You need to do :- code: One thing I realised working this out is that you can't do this :- i.e. I was trying to say copy all characters from position 13, bit of a shame that.code: |
That makes sense, thanks man , I really appreciate :)
|
Try this to copy all characters from position 13:
code: |
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:
code: and you want to extract just the part of the string.code: One way to do this is to cut off the last 22 characters and cut off the first character ("), as follows: code: 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 ! :) |
| All times are GMT. The time now is 22:28. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.