Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My laptop has a 14" widescreen: pretty wide, but not very high. I find it most convenient to have the Windows taskbar located on the left of the screen, since I can spare the width but not the vertical space.

However, when in the office, my computer sits in a docking station and is hooked up to a nice big squarish screen. Here I much prefer to have the taskbar in its default location i.e. at the bottom.

I know how to switch between the two taskbar locations manually in Taskbar Properties, of course. But I do this a few times daily, which is rather annoying. My question is: can I have the taskbar location change automatically?

For example, at startup (or wake up from hibernation) a script would run which detects either:

  • Is screen shape taller than 4:3? (or whatever number)
  • Is computer docked in docking station?

If yes, put taskbar at bottom, else at left.

Anyone know how to do this or can put me on the right track? Or is there already a utility out there that can do this?

share|improve this question
Set WshShell = CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set ObjRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

'Get curr. user name
Set colItems = objWMIService.ExecQuery("Select * From Win32_ComputerSystem")
For Each objItem in colItems
  strCurrentUserName = objItem.UserName

Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)
For Each objItem in colItems
  intHorizontal = objItem.ScreenWidth
  intVertical = objItem.ScreenHeight 

bottom = Array(&H28,&H00,&H00,&H00,&Hff,&Hff,&Hff,&Hff,&H02,&H00,&H00,&H00,&H03,&H00,&H00,&H00,&H3e,&H00,&H00,&H00,&H2e,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H82,&H04,&H00,&H00,&H80,&H07,&H00,&H00,&Hb0,&H04,&H00,&H00)
left_   = Array(&H28,&H00,&H00,&H00,&Hff,&Hff,&Hff,&Hff,&H02,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H3e,&H00,&H00,&H00,&H2e,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H3e,&H00,&H00,&H00,&Hb0,&H04,&H00,&H00)

if intVertical >= 800 then
  regdata = bottom
  regdata = left_
    end if

ObjRegistry.SetBinaryValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2\", "Settings", regdata

'Restart user shell
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'Explorer.exe'")
For Each objProcess in colProcessList
    colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)

If strUserDomain & "\" & strNameOfUser = strCurrentUserName then
end if


share|improve this answer
Welcome so SU! Rather than simply pasting code, please explain it a little. – msanford Feb 28 '13 at 14:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .