1
votes

When I tried to un-install and install an executable foo.exe, Im geting the below error

Error opening file for writing
click abort to stop the installation

I could find that some files were failed to get deleted while un-installation. And by using process explorer I can see that explorer.exe has still reference to some dlls of foo.exe even after unregistering them.

and killing the explorer.exe and re-start it again while un-installation solves the issue. (thru NSIS installation script).

or by setting rebook ok flag in script and ask user to re-start his machine before installing foo.exe again.

I don't think its a good solution to ask user to reboot his machine after un-installation .

Can anyone help me on how can I make sure that my installation goes fine instead of restarting explorer.exe

1
How are you executing the uninstaller? - kichik
I have the un-installer. Im executing with all the permission with UAC pluggin.. its not the issue with my UAC .(using XP) - Anees
I actually wasn't thinking of UAC, but rather your execution method not waiting for the uninstaller to properly finish and only continuing to the installer when it's really done. It's a very common issue with NSIS uninstallers. - kichik
HI kichik , I was reading one of your forum comments..about moving the dlls to temp and rename ..thats ok..I use RMDir /r /REBOOTOK "$INSTDIR" asthe last line of un-install script. this is after calling exec wait on registered dlls..deleteregkey everything.. - Anees
Still not what I meant... :) nsis.sourceforge.net/… - kichik

1 Answers

1
votes

For registered shell extensions there is really no clean way to delete the dll's other than forcing a reboot (Or log-off if they are registered in HKCU\Software\Classes)

If that is not good enough you basically have two options:

  • Rename the .dll and delete it later
  • <HACKALERT>Inject a thread that calls CoFreeUnusedLibraries() into every process that has your dll loaded</HACKALERT>

Just killing and restarting explorer is not really an option since you don't know if some other program is also using your shell extension.