Skip to content
⌘ NSIS Forum Archive

Close current explorer if current folder is deleted

3 posts

zjckwht#

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?
{_trueparuex^}#edited
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.
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
vitoco#
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?