locked
Collapse all folder-trees when closing Explorer RRS feed

  • Question

  • Unlike the drives listed in Computer/Windows Explorer, every folder that is also displayed on the Desktop (e.g. User, Libraries, Network, Control Panel) won't collapse automatically in the Navigation Pane when closing the Explorer. So most time I'm starting the Explorer, the first thing I have to do is closing the folder-trees of the directories I don't use and don't want to see expanded.

    Is there any possibility to change that annoyance?

    Sunday, April 17, 2011 1:29 AM

Answers

  • Hi, Mathrius:

    That state information is stored in the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane. If you delete the ExpandedState registry value, the next time you open Explorer it will show the "default" tree state.

    I'm not aware of a better way to reset that information, or always show the default state. Maybe if you remove the "Set value" permission on that registry key for your user... but that's a bit hacky and I don't know if it can cause other unwanted problems.


    Microsoft MVP Windows Expert Consumer | http://www.wintecnico.com

    Monday, April 25, 2011 3:05 PM
    Answerer

All replies

  • Hi Mathrius,

    Thanks for the post!

    Open the Windows Explorer, press Alt key, click Tools -  Folder Options.

    Under Navigation pane, do not check "Show all folders", click Apply and OK.

    Restart the Windows Explorer.

    Regards,

    Miya


    This posting is provided "AS IS" with no warranties, and confers no rights. | Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Proposed as answer by chandika94 Tuesday, January 29, 2013 12:03 PM
    Tuesday, April 19, 2011 8:54 AM
  • I still want to be able to access them quickly in the left nav-pane, I just don't want to see their sub-folders (cos they're expanded) when starting Windows Explorer.
    †I wanna live, I wanna love, but it's a long hard road out of hell!†
    Wednesday, April 20, 2011 2:57 PM
  • I'm afraid that behavior is by design.

    Regards,

    Miya


    This posting is provided "AS IS" with no warranties, and confers no rights. | Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, April 21, 2011 10:42 AM
  • Maybe some new start-parameter for the Windows Explorer?

    Sunday, April 24, 2011 1:10 AM
  • windows key + r

    type desktop then hit enter

     

    If this is what you want it to look like, then create a shortcut pointing to desktop, and use that to open explorer.

    • Edited by fearsyth Sunday, April 24, 2011 7:16 AM post did not format correctly
    Sunday, April 24, 2011 7:15 AM
  • Thanks, but I'm already using "explorer.exe /e," or "explorer.exe /e,E:" to start Explorer in the wanted directory. Unfortunately this won't prevent it from keeping open the unwanted folders on the Navigation Pane.
    Sunday, April 24, 2011 2:57 PM
  • Hi, Mathrius:

    That state information is stored in the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane. If you delete the ExpandedState registry value, the next time you open Explorer it will show the "default" tree state.

    I'm not aware of a better way to reset that information, or always show the default state. Maybe if you remove the "Set value" permission on that registry key for your user... but that's a bit hacky and I don't know if it can cause other unwanted problems.


    Microsoft MVP Windows Expert Consumer | http://www.wintecnico.com

    Monday, April 25, 2011 3:05 PM
    Answerer
  • Thanks Daniel, that's what I've been looking for. Since I can't find any other values/data in that key I guess removing the write-permission won't cause any other trouble.

    I've created a batchscript to quickly set the new default state of the expanded folder-trees when starting Windows Explorer.

    <batchscript start>
    @ECHO OFF
    :cmdstart
    ECHO.
    ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ECHO ~ Windows 7 Batchscript to avoid expanded directories ~
    ECHO ~ in the Nav-Pane after closing Windows Explorer.   ~
    ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ::Created by Mathrius/MK90 - Regards to Daniel M. from the TechNet-Forums / 29.04.2011
    ::TN-Thread:social.technet.microsoft.com/Forums/en-US/w7itproui/thread/48ebc898-290d-405f-b4d5-c3dc72278b76
    ECHO.
    ECHO Select an option and press enter:
    ECHO.
    ECHO [1] Set the new initial (fixed) expanded folders view
    ECHO [2] Set the expanded folders view back to default behavior
    ECHO [3] Open Explorer window
    ECHO [4] Exit Batchscript
    ECHO.
    set /p choice=
    ECHO.
    if "%choice%" == "1" goto fixnavpane
    if "%choice%" == "2" goto navpanedef
    if "%choice%" == "3" goto openexplorer
    if "%choice%" == "4" goto exitcmd
    ECHO Invalid option, please try again.
    pause
    cls
    goto cmdstart
    
    :fixnavpane
    (ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane [1 5 17])>"%TEMP%\reginicmd"
    regini "%TEMP%\reginicmd"
    ECHO.
    ECHO Expand/Collapse the folders of the Explorer Navigation Pane and close its window.
    ECHO (Only the folder-tree state of the 'desktop-subfolders' will be saved.)
    ::Or use "regedit /s regfile" or "REG ADD" to set the wanted "ExpandedState" data
    ECHO.
    pause
    (ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane [2 6 19])>"%TEMP%\reginicmd"
    regini "%TEMP%\reginicmd"
    ECHO.
    ECHO The permissions for the registry-key
    ECHO HKCU\...\Explorer\Modules\NavPane
    ECHO are now set to Read-Only.
    ECHO (New expanded folders view was set.)
    ECHO. 
    pause
    del "%TEMP%\reginicmd"
    cls
    ::goto cmdstart
    exit
    
    :navpanedef
    (ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane [1 5 17]
    ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane
    ECHO ;TestExampleValue = DELETE
    ECHO ;TestExampleValue = REG_BINARY 8 9 17)>"%TEMP%\reginicmd"
    regini "%TEMP%\reginicmd"
    ECHO.
    ECHO The Nav-Pane expanded folders behavior was restored.
    ECHO. 
    pause
    del "%TEMP%\reginicmd"
    cls
    ::goto cmdstart
    exit
    
    :openexplorer
    explorer /e,
    cls
    goto cmdstart
    
    :exitcmd
    exit
    <batchscript end>

    I wish every Windows 7 UI issue could be solved easily like this...

    • Proposed as answer by JonnyH3425675 Monday, September 30, 2013 12:36 AM
    Saturday, April 30, 2011 5:19 PM
  • Nice job! And thank you for sharing the script!
    Tuesday, October 6, 2015 8:14 AM
  • I'm afraid that behavior is by design.

    Meanwhile, Vista had them all collapsed by default.

    Windows 7 has so many more problems than Vista it's mindblowing how many people ride that "trash Vista" bandwagon when I've found 7 to be worse in so many ways, including basic text painting.

    Sunday, October 11, 2015 5:28 PM
  • Thanks Daniel, that's what I've been looking for. Since I can't find any other values/data in that key I guess removing the write-permission won't cause any other trouble.

    I've created a batchscript to quickly set the new default state of the expanded folder-trees when starting Windows Explorer.

    <batchscript start>
    @ECHO OFF
    :cmdstart
    ECHO.
    ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ECHO ~ Windows 7 Batchscript to avoid expanded directories ~
    ECHO ~ in the Nav-Pane after closing Windows Explorer.   ~
    ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ::Created by Mathrius/MK90 - Regards to Daniel M. from the TechNet-Forums / 29.04.2011
    ::TN-Thread:social.technet.microsoft.com/Forums/en-US/w7itproui/thread/48ebc898-290d-405f-b4d5-c3dc72278b76
    ECHO.
    ECHO Select an option and press enter:
    ECHO.
    ECHO [1] Set the new initial (fixed) expanded folders view
    ECHO [2] Set the expanded folders view back to default behavior
    ECHO [3] Open Explorer window
    ECHO [4] Exit Batchscript
    ECHO.
    set /p choice=
    ECHO.
    if "%choice%" == "1" goto fixnavpane
    if "%choice%" == "2" goto navpanedef
    if "%choice%" == "3" goto openexplorer
    if "%choice%" == "4" goto exitcmd
    ECHO Invalid option, please try again.
    pause
    cls
    goto cmdstart
    
    :fixnavpane
    (ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane [1 5 17])>"%TEMP%\reginicmd"
    regini "%TEMP%\reginicmd"
    ECHO.
    ECHO Expand/Collapse the folders of the Explorer Navigation Pane and close its window.
    ECHO (Only the folder-tree state of the 'desktop-subfolders' will be saved.)
    ::Or use "regedit /s regfile" or "REG ADD" to set the wanted "ExpandedState" data
    ECHO.
    pause
    (ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane [2 6 19])>"%TEMP%\reginicmd"
    regini "%TEMP%\reginicmd"
    ECHO.
    ECHO The permissions for the registry-key
    ECHO HKCU\...\Explorer\Modules\NavPane
    ECHO are now set to Read-Only.
    ECHO (New expanded folders view was set.)
    ECHO. 
    pause
    del "%TEMP%\reginicmd"
    cls
    ::goto cmdstart
    exit
    
    :navpanedef
    (ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane [1 5 17]
    ECHO HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane
    ECHO ;TestExampleValue = DELETE
    ECHO ;TestExampleValue = REG_BINARY 8 9 17)>"%TEMP%\reginicmd"
    regini "%TEMP%\reginicmd"
    ECHO.
    ECHO The Nav-Pane expanded folders behavior was restored.
    ECHO. 
    pause
    del "%TEMP%\reginicmd"
    cls
    ::goto cmdstart
    exit
    
    :openexplorer
    explorer /e,
    cls
    goto cmdstart
    
    :exitcmd
    exit
    <batchscript end>

    I wish every Windows 7 UI issue could be solved easily like this...

    This man is a god! THANK YOU

    FOR @#% SAKE this issue is / was / has been annoying for YEARS.

    I do not want libraries and I don't want my documents, to EVER expand, EVER.

    amazing, just amazing, thank you.

    Monday, January 11, 2016 12:03 AM
  • Thanks Daniel, that's what I've been looking for. Since I can't find any other values/data in that key I guess removing the write-permission won't cause any other trouble.

    I've created a batchscript to quickly set the new default state of the expanded folder-trees when starting Windows Explorer

    .........

    I wish every Windows 7 UI issue could be solved easily like this...

    Mate is it possible to provide that script again, as the DropBox link is dead.

    Tuesday, February 25, 2020 4:38 AM
  • If all you want is Explorer to open "clean" each time, then create a Powershell script with the following:

    Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\NavPane -Name ExpandedState -ErrorAction SilentlyContinue
    Start-Process -FilePath $env:windir\explorer.exe

    Use that to launch Explorer each time and you're golden!  

    Tuesday, March 17, 2020 2:36 PM