3

Windows has a few folders such as "Documents", "Pictures", "Downloads", etc... which can be accessed from the quick access bar on the left of Explorer or from the "Home" tab. Clicking the button to go up one level from these folders will bring you back to Home or Desktop, depending on how you got there in the first place.

These folders are really located in something like C:\Users\user1\Documents, or perhaps C:\Users\user1\OneDrive\Documents, so when I go up one level, I really want to go to C:\Users\user1\ or C:\Users\user1\OneDrive\.

Is there an easy way to do this?

Toto
  • 19,304
Edward
  • 183

1 Answers1

0

The following is valid for Windows 10, I haven't upgraded to 11, so no clue as to how Explorer behavior may have changed.


A coupl.e of years ago, I created a simple context menu entry for the Dorectory Bacground context menu:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\OpenLocation] @="&Open file-system location"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\OpenLocation\command] @=""explorer.exe" "%v""

It opens a new Explorer window to the file-system location of the folders under This PC,shell:UsersFilesFolder (user profile folder rooted at Desktop), etc. But opening a new window seems clunky. It seems "cleaner" to navigate within the existing window. So seeing this question made me re-visit and come up with this PowerShell snippet:

@((New-Object -com shell.application).Windows()).ForEach({
    Try{$_.Navigate2($_.LocationURL)}
    Catch{}
})

It will navigate all open Explorer windows that are currently displaying a namespace junction to their file-system locaiton.

To create a context menu shortcut to run this code without window flash:

$encodedCommand = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes( '@((New-Object -com shell.application).Windows()).ForEach({Try{$_.Navigate2($_.LocationURL)}Catch{}})'))

$CommandLine = 'cmd.exe /c start /min Powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand ' + encodedCommand

$Key = 'HKCU:\SOFTWARE\Classes\Directory\Background\Shell\NavToFSLocation'

[PSCustomObject]@{ '(Default)' = 'Open file-system location' 'Position' = 'Top' } | Set-ItemProperty -Path (mkdir $Key -Force).PSPath

New-Item -Path $Key -Name 'Command' -Value $CommandLine

If you prefer a .reg file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\Shell\NavToFSLocation] @="Open file-system location" "Position"="Top"

[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\Shell\NavToFSLocation\Command] @="cmd.exe /c start /min Powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand QAAoACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AYwBvAG0AIABzAGgAZQBsAGwALgBhAHAAcABsAGkAYwBhAHQAaQBvAG4AKQAuAFcAaQBuAGQAbwB3AHMAKAApACkALgBGAG8AcgBFAGEAYwBoACgAewBUAHIAeQB7ACQAXwAuAE4AYQB2AGkAZwBhAHQAZQAyACgAJABfAC4ATABvAGMAYQB0AGkAbwBuAFUAUgBMACkAfQBDAGEAdABjAGgAewB9AH0AKQA="

Keith Miller
  • 10,694
  • 1
  • 20
  • 35