PowerShell
# Enable "Expand to current folder" in File Explorer navigation pane
try {
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
$valueName = "NavPaneExpandToCurrentFolder"
# Create the key if it doesn't exist
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
# Set the value to 1 (enable)
Set-ItemProperty -Path $regPath -Name $valueName -Value 1 -Type DWord
Write-Host "'Expand to current folder' has been enabled." -ForegroundColor Green
Write-Host "Restart File Explorer for changes to take effect."
} catch {
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
}
Stop-Process -Name explorer -Force
Start-Process explorer.exeAll information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.