Archive: Close current explorer if current folder is deleted


Close current explorer if current folder is deleted
How to achieve?

When a folder is deleted by the installer, if meanwhile user is explorering the folder, he will receive something like "xxx is missed..", how to automatically close the specified explorer window when installer deletes a folder to avoid getting such error?


That's pretty trivial... :) You could try using the FindWindow function to find the folder window and then close it with SendMessage.

!include WinMessages.nsh
FindWindow $0 "CabinetWClass" "My folder name"
SendMessage $0 ${WM_SYSCOMMAND} 0xF060 0

It's not berfect, but should do the trick and if my memory serves me well, the "CabinetWClass" class name doesn't apply to all windows versions...

Edit: Yes my memory does great job. :) In some cases the class name is ExploreWClass. Also the SendMessage in my example didn't work.
http://forums.winamp.com/showthread.php?postid=1993053


I don't know why, but most of the time, if I'm browsing the dir that will be removed (the uninstall.exe file is run by double-clicking it), the browser jumps automagically to the next dir in the tree. There is no explicit SendMessage in my script. May be because the directory tree is being displayed in the explorer window?