Change the Windows 11 Taskbar Location with PowerShell

Image Description

Daily PowerShell #17

Scripting Windows Daily PowerShell

November 2, 2021

quote Discuss this Article

Windows 11 currently does not have the option to change the taskbar location in the settings dialog.

This post provides a PowerShell script to easily change the taskbar location.

Windows 11 Taskbar Registry Setting

The Windows 11 taskbar registry setting can be found in HCKU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3. The settings value of this key contains a binary blob that defines settings for the taskbar. You can adjust the taskbar location by change the 13th value of the structure.

The valid values are the following.

Left: 0
Top: 1
Right: 2
Bottom: 3

Set-TaskbarLocation Function

To simplify changing this value, you can use the following PowerShell function. It reads the current value of StructRects2 and sets the desired taskbar location. You’ll need to restart explorer for the option to take effect.

function Set-TaskbarLocation {
    param(
        [Parameter(Mandatory)]
        [ValidateSet("left", "right", "top", "bottom")]
        $Location,
        [Parameter()]
        [Switch]$RestartExplorer
    )

    $bit = 0;
    switch ($Location) {
        "left" { $bit = 0x00 }
        "right" { $bit = 0x02 }
        "top" { $bit = 0x01 }
        "bottom" { $bit = 0x03 }
    }

    $Settings = (Get-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 -Name Settings).Settings
    $Settings[12] = $bit
    Set-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 -Name Settings -Value $Settings

    if ($RestartExplorer) {
        Get-Process explorer | Stop-Process
    }
}

To set the Windows 11 taskbar to the top of the screen, use the following command line.

Set-TaskbarLocation -Location Top -RestartExplorer