Taming Microsoft Media Center

Rate This
  • Comments 0

So I'm still fighting to keep Media Center as the main TV system here at chez Derbyshire, despite the veritable aggro it seems to spew out at regular intervals. On top of the increasing vagueness of the program categorization in the guide (it seems to think that "The Only Way Is Essex" is a documentary), the habit of the TV tuners to go walkabout when asked to do three things at once causes huge disruption to my wife's carefully crafted soap recording schedule.

OK, so maybe the hardware is aging a little, and the TV tuner card isn't the best in the world, but I've yet to find a decent compact and quiet Media Center box to replace it. So once again this week I've been plying it with more custom kludge software in an attempt to stay ahead of the aggravation curve. So, yes, it's yet another post about how to manage Media Center...

I've tried using services that regularly reboot the machine on a fixed schedule, or that just restart hardware drivers and services, but none seemed to be the right solution. Both tend to fire up at inappropriate times (usually in the middle of a recording or when you're trying to watch something it did manage to record), and so I finally decided that a notification mechanism was the optimum answer.

Failures are not that common anyway, occurring generally a couple of times a month, so rebooting every night is overkill while rebooting once a week means an error might go on for five or six days (or until you reboot manually). I considered a system of restarting the computer only when an error is detected, but then you're back to the rebooting at inappropriate times problem - often it will continue to record most things when only one tuner has stopped working.

And, anyway, how do I detect when an error has occurred? The obvious way is to look in the Windows Event Logs. The log named Media Center (in the Applications and Services section) helpfully contains Error events when a tuner fails, and meaningful Warning events when a program fails to be recorded correctly. And I already have a utility that can read event logs, so I'm half way there.

So I set to and created a modified version of the Server Monitor service I use to monitor my main network servers by removing all of the unnecessary crud and adding a capability to specify three pairs of values for the event source name and the partial text of an event message that the service will search for in the logs. The service already supports running scripts, external programs, and sending email messages. It also writes its own events to the Application log so that you can set up Scheduled Tasks that run in the context of a specified user account (the service needs to run under the Local System account). This means that you can use batch files kicked off by an event-driven Scheduled Task to do things such as closing and restarting the Media Center UI.

Initially I played with firing off a script from the service to reboot the computer using the shutdown command, but (as noted above) it's not an ideal solution unless you need to be away from the house for a while and you need Media Center to look after itself. Instead I set it up to search twice a day for new events in the Media Center log with the source Recording or ehRecvr, and containing things like "failure" and "not recorded" in the error message, and to send an email listing all of the new warnings and errors.

You'll need an SMTP server to actually send the emails. I set up my internal IIS 6.0 SMTP Service that sends emails from the various services and devices on my network (such as UPSs, the NAS, and the server monitor services) to allow relaying for the Media Center machine, or you can probably relay through your own email provider (such as Hotmail) instead.

So far it's worked well. You can look at the recording history within the Media Center ten-foot interface and see if there really is a problem, and reboot from the Settings section of the home screen when required. All you need is a smartphone or tablet by your side that can receive emails, and you'll never need to leave your armchair again.

However, deleting the history entries in Media Center doesn't seem to delete them from the Media Center log file - I guess that Media Center just listens for new events and stores them in its own database. To prevent being repeatedly reminded of old events after restarting the computer I added a configuration setting to the service that can be set to force it to ignore any existing events. Alternatively, you can simply clear the Media Center log when you reboot the machine.

If you want to access Windows Event Logs from a remote machine, such as one that has administrative privileges on a Media Center box that's running under a user account, you'll probably need to enable the inbound Windows Firewall rules for "Remote Event Log Management" (click the Advanced link in the Windows Firewall dialog or open "Widows Firewall with Advanced Security" from the Start menu).

You can download the service I created for free, including the Visual Studio 2010 source code, from here if you want to give it a try - and maybe even adapt it to suit your own requirements. There's no limitations on how you use the code, and there's loads of configuration settings so it might be useful in other scenarios as well.

But be ready for your partner to suddenly mention in the middle of a conversation that they "just got an email from the TV"...

Leave a Comment
  • Please add 5 and 2 and type the answer here:
  • Post

Taming Microsoft Media Center