Archive: Uninstall Only Installed Files with excluded files


Uninstall Only Installed Files with excluded files
Hey guys,

I'm trying to uninstall only installed files, I read the examples page already, and that code seems to work fine with one exception, you can't exclude files... The wildcards work fine as they are recorded and included in the install. Then when the uninstall happens the wild card is read back in again and the files are deleted. However, you can't excude files. It is very important that I exclude certain files from being installed.

Can anybody think of an easy way to edit this code so that it will write out all the files I want excluding files I don't?


!macro File FilePath FileName
IfFileExists "$OUTDIR\${FileName}" +2
FileWrite $UninstLog "$OUTDIR\${FileName}$\r$\n"
File "${FilePath}${FileName}"
!macroend
!define File "!insertmacro File"


I need to use this macro with something like the following:
${File} /x CVS /x foo.bar "C:\myfiles\" "*.exe"

TIA -Greg


You can generate the code to add the files and delete the files outside of the installer using a scripting language or even a NSIS installer. Have it search for the files using wildcards, write down a File instruction for the installation and a Delete instruction for the uninstallation and then include the results in your script using !include.

This way, you could implement whichever logic you want, including file exclusion by name.


Hey, thanks for the reply.

That is actually the way I decided to implement it last night, and it works great, so...good suggestion!

Thanks
-Greg


Hi! I am trying to do uninstall only of installed files too. Here is the code in my main install section. Note that I have copied the code from the File macro directly here.

FindFirst $0 $1 "..\image\*.*"
loop:
StrCmp $1 "" done
IfFileExists "$OUTDIR\$1" +2
FileWrite $UninstLog "$OUTDIR\$1$\r$\n"
File "..\image\$1"
FindNext $0 $1
Goto loop
done:

So I get a compile-time error on the File instruction and it comes from the usage of $1 variable. If I put the name of a real file instead of it, it works. So I wonder is the problem that the File instruction is executed on compile time while all the other code like FindFirst and FindNext is executed on run time and that's why File instruction doesn't accept variables? If this is the problem how could I list all the files from a wildcard search in the uninstall log?


You may want to take a look at Advanced Uninstall Log


Thanks a lot! This is what I needed. I wonder only what is the "Install.exe" for and can I live without it?:)


Of course you can live without it!
It is there only to automate the procedure of adding the header into NSIS\include directory, the examples into NSIS\examples directory and the readme into NSIS\Docs directory ;)


Thanks again!:)