I have a folder on my Desktop named test
. I want to create a batch file in order to close the window automatically when this folder is opened with Windows Explo
It is not possible to close the Windows Explorer window of a folder using command taskkill
if in Windows registry under
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
the double word SeparateProcess has the value 0 respectively option Launch folder windows in a separate process on View tab of the Folder Options is not checked.
And as foxidrive found out (read comments below) and I can also confirm, enabling this setting has on Windows XP SP3 no effect on number of explorer.exe
running on opening folders even after a restart of Windows.
Therefore it depends on version of Windows (2000, XP, Vista, 7, 8, 8.1) and the Folder Options
if it is possible at all to use the command taskkill
to close an Explorer folder window and which string to find in title bar, just the name of the folder or the full path of the folder.
On Windows XP or with Launch folder windows in a separate process not being enabled the folder window is not opened as separate task respectively as separate process.
Independent on how many folder windows are opened, the number of explorer.exe
processes for each user is always just 1. Every folder window is in real just a window of always running Windows Explorer (desktop) opened in a separate thread. Windows Explorer just pretends that the folder window is a separate task on Windows task bar and on Applications tab of the Windows task manager. But only one explorer.exe
is listed on Processes tab of Windows task manager even with multiple folder windows opened.
This behavior of Windows Explorer can be better watched with free tool Process Explorer of Sysinternals by selecting explorer.exe and viewing in lower pane on the handles of this process containing among lots of other handles also the handles of the opened folder windows.
A console application is required which finds a window by title, get the handle of this window and sends the WM_CLOSE
event message to this folder window. See for example