Archive: Cancel / Revert changes when DLL is locked


Cancel / Revert changes when DLL is locked
Hi,

I want to cancel the deinstaller when a DLL file is still openend by another app, like IE.
How can I detect this?

I used the following code:

        # check if IE is locking 'hbxie.dll'
ClearErrors
FileOpen $R0 "$INSTDIR\hbxie.dll" w
${If} ${Errors}
# File is locked.
${Else}
FileClose $R0
${EndIf}


but this only works when INSTALLING, not deinstalling.
Also I'd like to revert changes when an error occured and the user clicked "cancel".
Is this possible?

I searched the forum, but the only solution I came up with so far is the above makro, which doesn't work when removing the file.

Take a look at the LockedList plugin.


Yes, I already found out about this one, and it seems to work fine :-)
But thanks for the tipp :)

The only thing I'm not sure how to do now is to do a revert.
Let's say installation fails at 67%, reasons unknown. The user presses Cancel, but the already installed files and registry keys are not removed.

Is there a built-in solution?


There is no built-in solution. There are however some header files that can help with semi-automated deletion of installed files:
http://nsis.sourceforge.net/Uninstal...nstalled_files
http://nsis.sourceforge.net/Advanced...og_NSIS_Header

I've never used them myself, so I can't help you there. Personally, I prefer doing everything myself, at least that way I know exactly what's going on. What I do is create the uninstaller as the first step in the installation process. That way I can rollback installation even if it fails halfway. (My uninstallers only remove what I know I installed myself, like every good uninstaller should.)


Another option:
http://nsis.sourceforge.net/Install_on_reboot

Stu