Close folder's window with batch file

后端 未结 4 2020
孤独总比滥情好
孤独总比滥情好 2021-01-06 18:32

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

4条回答
  •  日久生厌
    2021-01-06 19:26

    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

    • Display the full path in the title bar
    • Launch folder windows in a separate process

    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

    • How to close Windows Explorer from CMD?
    • How do I keep Windows Explorer from interfering with deleting a folder?
    • How to close Windows Explorer windows with opened folders from a certain drive?

提交回复
热议问题