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="