The Mystery of the Auto Hide Taskbar Setting

This shouldn’t have been a mystery, but it turned into one!  Recently, we pushed out a bunch of Windows 7 x64 kiosk type computers and discovered that we needed to hide the bottom task bar (it was covering part of the kiosk application).  Unfortunately, we had already locked down the AD account so tight that the user account didn’t have access to any control panels.  I figured this wasn’t a big idea and that this setting was probably controlled by a registry key.  Well, it is, but get ready for a bumpy ride!  Search around the Internet long enough and you’ll get a few answers where this value is stored, but the real answer is that Windows 7 keeps the auto hide taskbar setting in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ExplorerStuckRects2.  So what the heck is StuckRects2?  Well, I found this…a deep dive into this array value: http://www.dabcc.com/article.aspx?id=9724.  Yup, it’s no ordinary value and it controls various other taskbar settings.

I couldn’t find any historical reason for the name (someone e-mail Raymond Chen from Microsoft!), but my guess is it stands for Stuck Rectangle or that rectangle on the bottom of your screen that won’t go away.  This should be easy enough: check the box for auto hide taskbar, export StruckRects2 into a REG file and go on our merry way.  Well, that didn’t work!  After several more hours of searching, I found this web site: http://www.engincapat.com/windows-taskbar-autio-hide-scripts/ and a nice little VBScript file that did work logged in as the user:

Option Explicit
Const HKCU = &H80000001
Dim objReg
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}rootdefault:StdRegProv")
Dim objWMI
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}rootcimv2")
' Adjust the first bit of the taskbar settings
Dim arrVal()
objReg.GetBinaryValue HKCU, "SoftwareMicrosoftWindowsCurrentVersionExplorerStuckRects2", "Settings", arrVal
arrVal(8) = (arrVal(8) AND &h07) OR &h01
objReg.SetBinaryValue HKCU, "Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings", arrVal
' Restart Explorer for the settings to take effect.
Dim objProcess, colProcesses
Set colProcesses = objWMI.ExecQuery("Select * from Win32_Process Where Name='explorer.exe'")
For Each objProcess In colProcesses
objProcess.Terminate()
Next

The guy actually went through and documented each hex value and what it does.   So why does this work and not the REG file export/import?  There are two issues that I observed:

1) Explorer does not flush out this setting right away to this registry value.  If you make the change and then export it right away, you’ll export the same value as if it were unchecked.  I actually thought this was a bug in ProcMon since I could see the value being changed in SpyStudio, but not Procmon, but that’s because I wasn’t waiting long enough for explorer to flush out the value.

2) Even if you import the correct values, the value that was there before is written out by explorer.exe.

The only explanation I can come up with is that there are values in memory that explorer.exe uses and these are read in once at login and wrote out during logoff.  The only way to inject the correct value via a non-GUI method is to replace the value, then kill and restart explorer.  Explorer.exe will then read in our new value and life is good.

And just for reference: these are the settings for hide and no hide (note the red values)…

Hide

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2]
"Settings"=hex:28,00,00,00,ff,ff,ff,ff,03,00,00,00,03,00,00,00,3e,00,00,00,1e,
 00,00,00,00,00,00,00,66,03,00,00,40,06,00,00,84,03,00,00

No Hide

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ExplorerStuckRects2]
"Settings"=hex:28,00,00,00,ff,ff,ff,ff,02,00,00,00,03,00,00,00,3e,00,00,00,1e,
 00,00,00,00,00,00,00,66,03,00,00,40,06,00,00,84,03,00,00

– Soli Deo Gloria

1 thought on “The Mystery of the Auto Hide Taskbar Setting”

  1. To make this work on Windows 10, I had to change the registry key from StuckRects2 to StuckRects3. Other than that, I’m using the same script as I have for the last 4 years since we first implemented Windows 7.

Leave a Reply

Your email address will not be published. Required fields are marked *