Archive: Partial String Match During Uninstall


Partial String Match During Uninstall
How do I do a partial string match during an uninstallation routine?

We make a software product and now we have released a "viewer" version, which is a stripped down version of the main thing. Only issue is, there is one common icon on the desktop.

Typically they shouldn't co-exist, but I allow it anyway by doing something like this:


Function .onInit
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\NeatoTek" \
"UninstallString"
StrCmp $R0 "" goahead
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"NeatoTek 1.2 is already installed. $\n$\nClick `OK` to continue the \
installation of the NeatoTek 1.2 Viewer or `Cancel` to cancel this installation." \
IDOK goahead
Abort


goahead:
FunctionEnd


I adapted code from the uninstall if found before start routine actually.

But in the uninstall portion:


${If} $nt == "no"
; function here
Delete "$DESKTOP\Common Icon.lnk"
${EndIf}


I originally did a global var but since uninstall is an entirely different scope that didn't work. I wanted to use the same code below, and I am sure it would work, but I rather use the Display Name part of the registry, but for some reason, our product has the version number in it, whilst it also being in Display Version. Since we have released several released already too late for that change, but I rather use Display Name on the top portion too since I have a generic version in there, i rather output the var itself reads so i dont have to keep changing this with each release.

So my question is, how do i do the strcmp on that "Foobar 500" as display name and just search for foobar. The viewer has two words followed by the number, the full version I believe has one word with the number.

Any help is appreciated. I know I wrote a lot, but I think I confused things more than necessary so I hope I didnt!

thanks!

I'm not sure what you want exactly, but if you want the DisplayName without the DisplayVersion you can use the WordReplace function from the WordFunc Header, like

${WordReplace} "$DisplayName" " $DisplayVersion" "" "+" $R0

Or if you just want to check if a string contains another string, you can use
${WordFind} "$nt" "foobar" "#" $R0
${If} $R0 > 0
; function here
Delete "$DESKTOP\Common Icon.lnk"
${EndIf}

I figured my full story was more confusing what I want.

To summarise and make it more clear.

Our company produces a product that requires software to run it. It generates special kind of files.

If one did not own the equipment, but is interested in examining the data our devices produce they can get the free
viewer.

Lets call this Foobar Viewer 100.
So in its DisplayName portion of the Uninstall in the registry, we get "Foobar Viewer 100".

If the enduser does own our equipment, Lets call this now Neato 100. So its uninstall displayname parameter is now Neato 100.

What I am trying to accomplish is two fold.

During the installation of the Viewer, it determines if the full version is there by examining the value of Neato in this case.

Because a user can have Version say 1-infinity (since there will always be a newer version), I want to determine if they have Neato installed, under displayName.

However, since Neato and Foobar both share a common application that has a shortcut on the desktop, when one uninstalls the viewer (foobar), and if Neato is already installed, i don't want its icon to be removed. since both are sharing the same function, except in two different spots, I am trying to just find the name.

For now, I don't care what happens to the viewer if a user uninstalls the full version. Right now, however, my logic works, the appropiate icons stay/remove how i want them to do so, though i have to say If "Neato 100" else kind of deal.

I hope this did not make things more confusing but after reading and rereading this, I think this makes more sense.


I suggest doing a partial string copy (up to where the number begins) and then check that portion.

strcpy $1 "Foobar Viewer 100"
strcpy $1 $1 -4 # truncate 4 characters
${If} $1 == "Foobar Viewer"
MessageBox MB_OK "It works"
${Else}
${Endif}

Fantastic mate, thanks so much!

I reckon when we get to version 1000 the program will be called something else, I hope!

Actually, I think we will go with the full version (the number above is a build number, the full version is 6.3.100)


Well, as I mentioned above you can use the WordFind macro from the WordFunc library, so that it is independant of whatever version you have:

strcpy $1 "Foobar Viewer 100"
${WordFind} "$1" "Foobar Viewer" "#" $R0
${If} $R0 > 0
Delete "$DESKTOP\Common Icon.lnk"
${EndIf}