The following PowerShell script changes the StuckRects3 registry entry in the Windows Registry in order to reposition the Windows Taskbar. The StuckRects3 registry entry can be found under the following current user registry key:
HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3
Once the registry entry has been changed the code stops the explorer process (which Windows will then automatically restart) and the taskbar is repositioned. Valid values for the StuckRects3 registry entry are 0, 1, 2 and 3 which correspond to left, top, right and bottom respectively.
Please note that this code works perfectly on Windows 10, however does not seem to work when run under Windows 11 22H2. Once I have figured out a way to do reposition the taskbar under Windows 11 I will update the code accordingly.
#----------------------------------------------------------------------------#
# Program Copyright : Mike Wilcock.
# Program Name : tb_move.ps1.
#----------------------------------------------------------------------------#
# Program Created : 27th April 2022.
# Program Code Type : PowerShell Script (version 5.1.19041.1023).
# Author : Michael Wilcock, IT Technician.
#----------------------------------------------------------------------------#
# Version : 1.00
#----------------------------------------------------------------------------#
# Purpose : Reposition the Windows task bar either top[1], left[0], bottom[3] or right[2].
#----------------------------------------------------------------------------#
clear screen
# Prompt user.
$tb_pos = read-host "Please enter task bar position - Top[1], Left[0], Bottom[3] or Right[2]"
# Very simple validation.
if($tb_pos -eq 0 -or $tb_pos -eq 1 -or $tb_pos -eq 2 -or $tb_pos -eq 3)
{
# Task bar position registry key.
$RegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'
# Retreive existing registry value.
$NewValue = Get-ItemProperty -Path $RegistryPath
# Set new registry value.
$NewValue.Settings[12] = $tb_pos
# Update registry value.
Set-ItemProperty -Path $RegistryPath -Name "Settings" -Value $NewValue.Settings
# Stop explorer process. Will automatically restart.
Stop-Process -Name "Explorer"
}
# User can't read.
else
{
clear screen.
write-host "Invalid input entered - Valid values are: Top[1], Left[0], Bottom[3] or Right[2]"
}
See Also