In my uninstaller, i try to delete some files and directories.
Ex:
delete "$INSTDIR\images\*.*"
rmdir "$INSTDIR\images"
But the result is different each time i run the uninstaller, one time every files and directories are deleted, one time some files and directories are exists.
How to make sure files and directories are deleted after uninstall ?
How to make sure files and directories are deleted after uninstall ?
8 posts
If you're sure you want to delete a directory you can use:
This way you'll delete the directory recursively - all files and subfolders will be deleted too.
And are you checking for errors after Delete/RMDir?
instead of using Delete+RMDir on the same directory.RMDir /r
This way you'll delete the directory recursively - all files and subfolders will be deleted too.
And are you checking for errors after Delete/RMDir?
Also:
If you add the /REBOOTOK switch it will remove the directories on the next reboot if the installer is unable to.
If you add the /REBOOTOK switch it will remove the directories on the next reboot if the installer is unable to.
RMDir /r /REBOOTOK ${DIRTOKILL} Originally posted by ChocJunkie
And are you checking for errors after Delete/RMDir? [/B]How to check for errors ? I think may be when i deleted these files they were in use.
If you add the /REBOOTOK switch it will remove the directories on the next reboot if the installer is unable to.Thank you for your suggestion, i want to know the detail errors when i can't delete a file. In my circumstance, i know that it doesn't necessary to reboot computer.
Try this...
ClearErrors
RMDir $INSTDIR
IfErrors +1 NoErrors
DetailPrint "Everytime an error occurs, God kills a kitten."
NoErrors: In order to simple, i try :
ClearErrors
RMDir /r $INSTDIR
IfErrors +1 +2
MessageBox MB_OK "Can't delete"
I got that message box ! I also reinstall and try to uninstall again, that time no error. Why one time i can't delete a file, and other time i can. How to make the result always the same.
ClearErrors
RMDir /r $INSTDIR
IfErrors +1 +2
MessageBox MB_OK "Can't delete"
I got that message box ! I also reinstall and try to uninstall again, that time no error. Why one time i can't delete a file, and other time i can. How to make the result always the same.
These files were in used when the uninstaller try to delete.
Try:
RMDir /r /rebootok $INSTDIR
And after reboot my computer, these files were deleted. In order to avoid reboot, the application must close before the uninstaller run. How do i know if my application was running, and exit it ?
Try:
RMDir /r /rebootok $INSTDIR
And after reboot my computer, these files were deleted. In order to avoid reboot, the application must close before the uninstaller run. How do i know if my application was running, and exit it ?
you can implement a DDE server in your application (quite easy under MFC) and use nsisDDE plugin to detect and exit your running application