Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 12th October 2011, 07:50   #1
balu.g12
Junior Member
 
Join Date: Oct 2011
Posts: 2
Exclamation Skip deleting Modified/Added files and folders duirng Uninstall

Hi,

Presently i am deleting the Installed files/folders in uninstall section by using RMDIR /r $INSTDIR


But user may modify some installed files or he may add some directoires/files anywhere under $INSTDIR after installation.

I wanted to know,
During uninstallation, if there is any way to skip the deletion of some folder and its contents, if that folder has a modified files in it..

Can some body suggest me the solution with small example please?

Appreciate your help!

Regards,
Balaji.G
balu.g12 is offline   Reply With Quote
Old 12th October 2011, 11:05   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You should never rmdir /r $instdir, exactly because of the reason you mention: The user might have added files of his/her own. (Also, the $INSTDIR variable in the uninstaller only contains the directory where uninstall.exe is stored. So if the user moves uninstall.exe, you'll end up deleting files not belonging to your app at all!)

The solution is however not to 'exclude' some files. The solution is to include only those files that you KNOW you want to delete. To do this, you must simply add a delete command for every single file that you install.

If you think that's ugly, keep in mind that the user will never see the code to begin with. They will however notice what you end up deleting from their system. And deleting the entire Program Files folder just because the user installed there instead of in a subdir, now THAT is ugly.


(Note: to circumvent the problem with $instdir in the uninstaller, you need to verify that the folder is the correct one: Load the install path from registry, and/or check for some marker files specific to your application.)
MSG is offline   Reply With Quote
Old 12th October 2011, 12:21   #3
balu.g12
Junior Member
 
Join Date: Oct 2011
Posts: 2
Hi,
Just before posting my question, i read about consequences of using rmdir /r $instdir and i have planned to load the install path from registry instead of using rmdir /r $instdir.
Thanks for the suggestion.

##simply add a delete command for every single file that you install##
some of the problems, why i have left this idea is :
1) I have Thousands of files which i i will copy during installation.
2) I don't have any/proper idea on how to checkfor/getthelist of modified/New files.

{{My thinking is as follows:
while copying the files(File /r dir\*.*) during installation - redirect the each filename with path and time stamp to a file_timestamp.log file
while uninstallation - from the file_timestamp.log read every filename and verify if the time stamp is matching or not.
If the file timestamp is changed donot delete the parent folder and its contents.
Else Delete the file and empty directories.

?? but i am not sure how to get the file timestamp of a file and verify it??
}}

I am new to NSIS, Can you please suggest me how to proceed on this.
balu.g12 is offline   Reply With Quote
Old 12th October 2011, 13:16   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
To do that, you'll need to create an exe/vbs/bat file that creates a filelist at compiletime, and saves it as NSIS code such as "File dir\subdir\file1.ext", with the appropriate SetOutPath commands for the subdirs. Then !include that nsh code so that that the compiler can add them to the installer exe. You can create a textfile with timestamps at the same time, and parse that in the uninstaller (use File "dir\timestamps.txt" in the uninstaller section, and then some parsing functions from for example wordfunc.nsh). Tricky, but possible.
MSG is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump