Saturday, May 4, 2013

The Living Room PC, User Shells, and the Long Logoff Goodbye...

The Turing Box, my HTPC, lovingly named after mathematician
 and computer scientist Alan Turing

In a past post I mentioned that I was building an HTPC of which the lion's share of purpose was going to be towards living room gaming. One of my goals of the project was to create a device that was going to resemble more of a living room appliance (but of which I had full control) than a personal computer. To accomplish this, I removed the Windows branding, changed the login background screens to an image of my own choosing, and even created a custom startup animation (pictured above).

The last piece of the puzzle was removing windows explorer altogether when the user logged in. The visible effect of this is when logging in the user no longer sees the desktop, but instead only sees the application that runs as a shell. Why would one want to do this?

  • Performance - By having this program be the only one running (besides some windows services), it will have majority use of windows resources. This also cuts down on a lot of windows activity that comes along with launching explorer.
  • Start Time - The start time of the program (as a shell) is near instant.
  • Stability - As the only application running, the chance of conflicts decrease.
  • Clarity - When the user goes straight to the shell there isn't any discerning of purpose; you are up and running!
  • Cool Factor - It's just extra geeky cool to build your own appliance!

Now to accomplish this you have to substitute another program as a shell. In this you have a couple of options. You can replace the complete shell or on a by user basis. The complete shell wasn't really what I wanted to do, I wanted the logon screen to be present. I just wanted each user to have a separated shell or concern. Basically, on the Turing Box your "users" are nothing more than buttons to start an activity.

Some of the activities on the Turing Box

So next I'll explain how I setup one activity, "Play," on the box. I'll then talk about a nasty bug I ran into that took trial and error to figure out. Keep in mind this isn't a detailed tutorial, just a discussion about the major things I changed. I won't go into the customization of login background screens or startup animations... maybe in another post!


Setting Steam as the Alternate Shell

NOTE: This article talks about changing your registry. Only attempt if you really do know what you're doing (or could care less about wrecking your PC). Even then, proceed at your own risk. There really isn't anything in here that *should* be that dangerous, but I've seen people dazzle with how much damage they can dole out with seemingly no opportunity.

First things first, you should have one administrator account which is active and not part of these shenanigans. I make the other accounts, normal user accounts. This is to enforce the principle of least privilege for both security and consistency (each of these activities is a concern, or task, and none of them involve installing software). 

So, from within your "Play" account launch Steam and start it in Big Picture Mode (using the "Big Picture" button in the upper right hand corner of the Steam interface). Click the Gear Icon ("Settings") and then select the Account menu item. Finally check the "Start Steam in Big Picture Mode" option.

Setting Steam to start in Big Picture Mode

Note that I am participating in the beta. You don't have to but, at least currently, I'd recommend it. There is a Direct3D bug, causing frequent crashing of the steam client,  that was introduced to Windows 7 through the IE10 install (whether or not you use the browser) and the latest beta client corrects for that. Ok that's it for Steam. Now on to the registry!

It's important that you change the registry key while logged into the "Play" user account. You'll be changing the HKEY_CURRENT_USER key and you wouldn't want to change the wrong one! Go ahead and open regedit (WinKey+R -> type "regedit" without the quotes).

Obviously at this point you'll want to back up your registry. Browse to and export the following key somewhere safe.

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon]

In this key you will want to create a new string value and name it "Shell" (without the quotes).

Add the Shell String Value
Now, Double click on the "Shell" value and add the path to the Steam client. For example:

C:\Program Files (x86)\Steam\Steam.exe

And that's it! If you log off and log on as "Play"  it should go straight to Steam in Big Picture Mode. Now here are a couple of things to keep in mind:


  • Steam right now doesn't have a "Log off" feature from the GUI's power menu. To log off, Press CTRL+ALT+DELETE and select Log off from the menu.
  • To temporarily bring up a desktop (say if steam crashes and all you have is a black screen), simply press CTRL+ALT+DELETE, and start task manager. Click the "New Task..." button on task manager and type "explorer" (without the quotes) followed by enter. That will get you a desktop. Note: In newer versions of windows, this might not be possible to bring up explorer in this way. If you experience this, simply open regedit and change the key to "xShell" signout and sign in and you should see explorer. When done change back to "Shell" signout/sign in. 
  • At any time if you want to restore explorer as the shell, go to the key above logged in as the "Play" user (and be careful that it is the key above), select the shell key value (it should have that Steam path) and delete it. When complete there should not be a value called "Shell" at all there. Log off and log back on and you should be back to the usual Redmond experience!

Logging off is so hard to do...

And that brought me to the proverbial fly in the ointment. Everything was working swimmingly... until I logged off. It took forever. How long varied, but it took over an hour at one point! This behavior did not occur when I logged off with explorer as the shell.

I tried so many things to find out what this was. But every rain dance I tried yielded no, well, rain.

Finally I started from scratch and did a clean boot. This is where you launch msconfig.exe, hide Microsoft services and disable everything. It worked! The log off was under five seconds. I then proceeded to add back in the startup processes and then the services, one by one until it failed. It was the last service. I kid you not. The culptrit? The Broadcom Wireless LAN Tray Service. I disabled this and everything worked as expected!


Last Thoughts

And there you have it. For each user you want to add simply repeat these steps adding a different exe for the shell and you should be good to go. A word of advice if it is a browser: use Firefox and not Chrome. Chrome doesn't render pages properly without explorer running. Not only does firefox render fine, it is naturally written to behave as you would expect in a sort of "Kiosk" mode.

Hopefully this helps you on your quest for the perfect living room PC experience. Happy shelling!