Archive: Automatic generation of Detele items in Uninstall section


Automatic generation of Detele items in Uninstall section
I am using "File /r path_to_application/*.*" to install all files for my application. Is it possible to somehow get NSIS to keep track of this list of files, and automatically generate the Uninstall section with "Delete" commands for each file?

From my reading and searches, it appears that there are only two ways to remove the application. The first is to manually enter "Delete" commands for each file, which is too tedious when the application is large and the list of files changes often. The second is to use an "RMDir /r "$INSTDIR"" statement, which I don't like because it will remove any other files that the user put into the installation directory.

Is there any way to accomplish this automatic uninstallation?

By the way, I am new to NSIS (looks VERY cool so far!), so hopefully I didn't miss something obvious. I couldn't find the answer in any of my searches.


You can create a macro so you only have to enter all filenames once or let the installer create a log-file with all filenames and delete these files when uninstalling.


Hi mfreed and welcome to the forums :)

Well, if you want to do that I'm afraid you'll have to write a couple of functions...

Actually there are several ways to achieve that.

You can for instance write a wrapper (macro) for the 'File' command that would write the files/directories into an Ini file. Then write a function for the uninstaller that loops through the files/directories read from the Ini file to remove them.

The 'problem' with this method is that if your application is big and has a lot of files/directories, it takes a little time during installation to write all the entries in the file.

In this case, an alternative could be to write the files/directories in the Ini file using an NSIS function *BEFORE* the compilation of your script. Then put this file in your installer (File myIniFile.ini), and at runtime just write the installation directory in the Ini file. This would save some time, but it's only worth it if your application is really big...

You can also check this thread but only half of it is relevant to your problem:

http://forums.winamp.com/showthread....hreadid=146048

evilO/Olive


Ooops, didn't see you answered Joost :p


Thanks for the suggestions evilO and Joost!

The only thing I am still missing is how I get NSIS to give me the list of files that it is including when I use a "File /r *.*" command. Or are you suggesting that I write my own recursive file inclusion macro, so that I can get each filename individually?

I think I am now at the point where I might make a separate (C++) executable that I run before I run NSIS, which recursively goes through the files and builds up a .NSI file.

Might be a good feature suggestion to have a "AutoGenerateUninstall on" command that tells NSIS to record everything that it does on the install side of things, and then builds an Uninstall section that reverses the process. Just a thought.