Archive: Make the uninstaller "remember" what was installed?


Make the uninstaller "remember" what was installed?
Hi.

I know this is most likely a very newbie question, and is probably very easily solved(maybe even the uninstaller solves it for me automatically), but I can't seem to find this exact info.

What I need to know, is:

How can I make the uninstaller "remember" what files the user chose to install, and then only attempt to remove those files?

You're probably thinking "Why don't you just list all the files in the uninstaller, so it will remove all of them, disregarding the files it doesn't find?"

Well, the problem there is that - let's say a "client" of mine chooses to only install one of my files. So he checks that checkbox only in the installer.

Then later he downloads files that another guy has made, and installs those. In my case, those files will have the exact same file names that I use, and I can't change that.

So let's say he now decides to use my uninstaller to remove the one file he installed from me.

-Now my uninstaller will remove all the files it finds(that I have listed I mean), and that will include the files he downloaded from the other guy.

And I don't want that.

(unless I'm mistaken and the uninstaller already 'knows' what to uninstall based on what the user installed)

So somehow I need the uninstaller to know what files the user chose to install, and only remove those files.

Is this easily done? Or does the uninstaller somehow already sort this out automatically?

Sorry if this has been answered numerous times already.
I searched the forum for "uninstall" and didn't find this.

In case it's a special script, please give me a short example of how to use it.

Thank you.


It's not that difficult. Depending on what you need, you can store the filenames in a registry key or file.


That would work for basics Joost. However, he stated that the files could be replaced by another application, therefore, meaning they'd have the same name and be in the same location.

What you will need to do is store the information as Joost explained, then check the file attributes using the system plugin to verify that the file is actually yours by comparing the file version tab information with the hard coded information you had stored in the installer at compile time.


Originally posted by zimsms
That would work for basics Joost. However, he stated that the files could be replaced by another application, therefore, meaning they'd have the same name and be in the same location.

What you will need to do is store the information as Joost explained, then check the file attributes using the system plugin to verify that the file is actually yours by comparing the file version tab information with the hard coded information you had stored in the installer at compile time.
Thanks(both of you).

Woah - a little more complicated than I thought...

So - I use a WriteRegStr for each of the install file sections, and then in each of the uninstall file sections, I use a ReadRegStr and somehow compare the read string with the written string(?).

But hey - I really need an example here.

-How do I use the System.dll to find this info, how do I make it compare what it finds with the install reg keys, and how do I tell it to use that info to not uninstall the files that don't match the original reg key?

I found this script - can I use any of that with a few modifications?

I'm beginning to think this is a bit over my head...

[EDIT] Or - come to think of it - maybe I could write a registry key for each installed file, then make the uninstall section search for each of those strings one by one. -If it then finds 'my' string, it will delete both the file and the reg string. If it doesn't find my reg string for that file, it will not touch the file.
And so on for all files.

Would that be a solution, you think?[/EDIT]

It would take me too long to actually provide a complete example.

Here's a little pseudocode for ya:

During install loop through the files and write the complete install information to an ini file (for easier access), or the registry. Both have their pros and cons. ie Files can be deleted, registry can be restored etc. The above loop would contain the same System call as defined below in the uninstall; only this time for the file being installed.

On uninstall you will need to read in a value from the step above looping until there are no values left. This part is easier in an ini file. Within the loop you will want to perform a system call to the GetFileInfo function and obtain the desired information. I believe there is an example of calling this function in the new system plugin.
Then you use a StrCmp to compare the stored value against the obtained values.

It is a big process, however, there are many examples of doing each of the pieces seperately.

I hoped the above can help you. If I get any free time I will attempt to make an example. Though I don't see this happening in the near future.


Or - come to think of it - maybe I could write a registry key for each installed file, then make the uninstall section search for each of those strings one by one. -If it then finds 'my' string, it will delete both the file and the reg string. If it doesn't find my reg string for that file, it will not touch the file.
This would work for files with filenames that you don't know about, but not for files that may of had the same name which replaced your files. This was one of the snags you requested.

Yes, I see you're obviously right, when I just get my brain working. :D

I'll have a look at what you wrote, and see if I can make it work. Could be I end up ignoring the problem and just give a warning that the files he has installed(other than mine) may be deleted. But I'll try to make this work first.


The best way is definately to store the filenames installed in the registry and then read them back out to the installer and then compare versions. Pretty much foolproof.