end2endzone / ShellAnything

ShellAnything is a C++ open-source software which allow one to easily customize and add new options to *Windows Explorer* context menu. Define specific actions when a user right-click on a file or a directory.
MIT License
183 stars 27 forks source link

Refresh script #85

Closed GasDauMin closed 3 years ago

GasDauMin commented 3 years ago

We have register.bat and unregister.bat scripts, but the unregister.bat script without restarting explorer not so useful, maybe it would be good to have a refresh.bat script which, after reloading explorer.exe, would return at least to the directory where that script was run.

end2endzone commented 3 years ago

I understand what you mean and I do see how useful such a script could be.

On a side note: on my Windows 10 machine, I do not need to call refresh.bat. When I call unregister.bat all instances of explorer.exe release their hook on shelext.dll (they stop using it) and I can rebuild the project without having a "unable to write to shellext.dll" kind of error message. Its been 1-2 months since I last verified but I doubt the recent commits have changed this behavior. When explorer.exe can flush its hook on shellext.dll can be identified in the logs with entries like the following:

I1224 09:50:34.189147 16212 shellext.cpp:1085] DllCanUnloadNow() -> Yes

explorer.exe should "periodically" check if the shell extension is still required. Once a "Yes" is sent back to explorer, explorer should release its hook on the shell extension's dll file. I don't know much thing about how the period is calculated but if I remember correctly, I think that calling "unregister.bat" should force explorer.exe to call DllCanUnloadNow().

Also not that all this does not work on my Windows 7 machine and I do have to call refresh.bat to refresh all explorer.exe instances.