- NSIS Discussion
- Delete and/or RMDir
Archive: Delete and/or RMDir
YooperNC
29th March 2004 22:44 UTC
Delete and/or RMDir
I'm using the latest full release of NSIS, 2.0. My installer creates a directory that isn't in or near the $INSTDIR. When I go to Delete files from that directory or when I try to RMDir that directory, nothing happens. No ErrorFlags are set. I have tried just about everything. I even went so far as to store the created directory in the registry and read it back out during Uninstall. I posted a MessageBox to myself, verifying that the string is correct.
Has anyone else seen this? Is it a known problem? Or is it "Operator Error". There's not much to see in my script, but if you want some pieces cut out of my installer, let me know, and I'll be happy to post them here.
Any and all help would be greatly appreciated. Thanks!
Dave
deguix
30th March 2004 03:19 UTC
RMDir - 2 possibilities:
Without /r [as a parameter], the directory will only be removed if it is completely empty.
If /REBOOTOK is specified [as a paramenter], and the directory cannot be overwritten, then the directory will be deleted when the system reboots... [so] the reboot flag will be set [but not the error flag].
Delete - 2 possibilities:
The error flag is not set from trying to delete a file that does not exist.
If /REBOOTOK is specified and the file cannot be deleted then the file is deleted when the system reboots... [so] the reboot flag will be set.
pol
30th March 2004 10:37 UTC
Perl script to list all files
Hello,
I have made a simple perl sript to list all files of your project with RMDir and Delete instructions.
This is very usefull if your project have a lot of files (more than 2000 in my case) and if you want to make a clean and complete uninstall.
The result is saved in a separate file. You will need to add
!include "uninstall.nsh"
in your uninstall secion
The uninstall.nsh will look like this:
Delete "$INSTDIR\webdav\tomcat.gif"
Delete "$INSTDIR\webdav\tomcat-power.gif"
Delete "$INSTDIR\webdav\index.html"
Delete "$INSTDIR\webdav\WEB-INF\web.xml"
RMDir "$INSTDIR\webdav\WEB-INF"
RMDir "$INSTDIR\webdav"
Delete "$INSTDIR\tomcat-docs\index.html"
RMDir "$INSTDIR\tomcat-docs"
...
Philippe
YooperNC
30th March 2004 14:04 UTC
Nowhere in the documentation do I see a "/REBOOTOK" for RMDir. Also, I have tried all combinations of "RMDir /r ...", "Delete /REBOOTOK ...", etc., and nothing has worked. Even after rebooting the OS, the files are still there. I get the subdirectory from the registry just fine with:
ReadRegStr $R6 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT_NAME}" \
"UninstallVideoLoc"
I've tried:
Delete "$R6\*.*"
Delete /REBOOTOK "$R6\*.mpg" ; still there after reboot
RMDir /r "$R6"
RMDir /r $R6 ; thinking the quotes were causing a problem
I am able to remove other directories, namely $INSTDIR, but this one is being stubborn. My collegues and I are stumped. Has anyone else had luck removing files that are not in the $INSTDIR (for example)? If so, can you share some insight? Thanks!
Dave
deguix
30th March 2004 14:28 UTC
Hmmm... nowhere... What NSIS version are you using?
pengyou
30th March 2004 15:54 UTC
YooperNC wrote:
>>I'm using the latest full release of NSIS, 2.0.<<
>>Nowhere in the documentation do I see a "/REBOOTOK" for RMDir.<<
From the NSIS 2.0 manual:
4.9.1.8 RMDir
[/r|/REBOOTOK] directory_name
Remove the specified directory (which should be a full path). Without /r, the directory will only be removed if it is completely empty. If /r is specified, the directory will be removed recursively, so all directories and files in the specified directory will be removed. If /REBOOTOK is specified, and the directory cannot be overwritten, then the directory will be deleted when the system reboots -- if the directory will be removed on a reboot, the reboot flag will be set. The error flag is set if the directory cannot be removed.
YooperNC
30th March 2004 20:27 UTC
Ok. Now I see that /REBOOKOK was added to RMDir. Thanks for the clarification.
But that still doesn't help me out. Like I said, I've tried all manner of combinations and permutations of the parameters, and nothing gets rid of these files. At one point, I noticed that the files contained within this directory were "Read-Only". However, removing this attribute made no difference.
Could it be a problem that I'm running on Windows XP? (I could blame Bill Gates, then)
I could always just tell the user to delete the files after Uninstallation is complete, but I'd rather not.
Thanks to all for your time.
Joost Verburg
30th March 2004 20:34 UTC
It should work fine. Please post relevant script code and details.
YooperNC
31st March 2004 21:34 UTC
Here's the script that I'm executing:
ReadRegStr $R6 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT_NAME}" \
"UninstallVideoLoc"
RMDir /r $R6
Sleep "200"
I've placed a MessageBox between the ReadRegStr and the RMDir, so I know that $R6 has exactly what I expect in it. I have also tried this:
ReadRegStr $R6 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT_NAME}" \
"UninstallVideoLoc"
Delete /REBOOTOK "$R6\*.*"
Sleep "200"
Each time, the files are still there. $R6 is:
C:\Video Files\test
This subdirectory contains the following files:
b281_20021230_162454.mpg
b281_20030103_124700.mpg
b281_20030109_142723.mpg
b281_20030225_095223.mpg
b281_20030226_102234.mpg
c122_20021222_090342.mpg
c353_20030305_161208.mpg
c353_20030309_000920.mpg
c353_20030309_004436.mpg
There's nothing wrong with this directory string that I can tell. And the files are nothing more than random video files varying in size from 19KB to 102KB. They are not read-only, so no use asking that question.
I've also placed "ClearErrors" and "IfErrors" around the RMDir and Delete commands, but no errors are set. It just goes along thinking that it did its job.
We're all stumped here. This problem defies logic and reason. If you have some time and like solving tough problems, feel free to create a subdirectory like the one above, fill it with some files, and put those script lines in your Uninstall section. I'd be very interested to hear your results. Thanks!
Dave
Joost Verburg
31st March 2004 21:58 UTC
The files are either in use or you have a wrong directory name.
Try to add it manually (without the registry key) and make sure the directory is valid.
kichik
2nd April 2004 05:17 UTC
That registry key probably contains a line break, quotes or a space. Use
MessageBox MB_OK *$R6*
and make sure nothing is between the unquoted path and the asterisks.
A similar case is presend in the FAQ:
http://nsis.sourceforge.net/support/...&tx_faq_faq=20