Home / Windows 7

Maintaining Windows Home Server

Computers are useful beasts that do some pretty amazing tricks. However, one trick they haven't yet mastered is selfmaintenance. Most of our other appliances run for years without much tending, but our computer appliances, being much more complex than your average microwave, require near-constant doses of digital TLC to keep them humming and happy. Fortunately, we're starting to see a trend toward self-maintenance in the PC world:

  • Windows 7 and Windows Vista machines automatically defragment themselves once a week, and a background service monitors hard disk health and reports on problems that it finds.
  • Windows Home Server automatically deletes old backups and installs updates every Sunday.
  • In this article, you learn that Windows Home Server automatically checks for errors on your installed hard drives.

These are a good beginning, but we're still an awfully long way from reaching the Holy Grail of self-maintaining computers. For example, if it's no big deal for Windows 7 and Windows Vista machines to defragment themselves regularly, why didn't Microsoft add the same capability to Windows Home Server? Not to worry, though: In this article, you learn not only how to perform a few essential maintenance chores in Windows Home Server, but how to automate most of those chores so that you have a few less things to keep on your to-do list.

Checking System Uptime

In networking parlance, uptime refers to the amount of time that some system has been running continuously since the last time the system was started. From the standpoint of Windows Home Server, the longer the uptime the better, because that means the server has been available for clients longer, which means that shared folders, media streaming, and remote access have all been available. Checking the system uptime isn't a crucial system maintenance skill, but it does give you some indication of how the system is running overall. These next few sections take you through various methods for checking the current uptime value.

Displaying Uptime with the Task Manager

Probably the easiest way to get the current system uptime is to use Task Manager. Log in to the Windows Home Server desktop, right-click the taskbar, and then click Start Task Manager. Display the Performance tab, and look for the Up Time value in the System section.

Displaying Uptime with the SYSTEMINFO Command

The SYSTEMINFO command-line utility gives you a tremendous amount of information about your computer, including data about the manufacturer, processor, and memory, what hotfixes are installed, and what network devices are installed. It also tells you the date and time when the system was last booted:

System Boot Time: 9/23/2012, 8:26:41 AM

Unfortunately, the output of the SYSTEMINFO command is quite long, so locating that one line can take some time. To make things faster, pipe the output of SYSTEMINFO through a case-insensitive FIND command, like so:

systeminfo : FIND /i "boot time"

This forces Windows Home Server to display just the System Boot Time line.

Displaying Uptime with Performance Monitor

Learned how to monitor Windows Home Server's performance using counters that you add to the Performance Monitor. One of those counters also tells you the current system uptime. Follow these steps to add it:

  1. Select Start, Run, type perf, and press Enter. The Performance Monitor appears.
  2. Select Monitoring Tools, Performance Monitor.
  3. Right-click the Performance Monitor graph, and then click Add Counters.
    (Alternatively, press Ctrl+I or click the Add button in the toolbar.) The Add Counters dialog box appears.
  4. In the Available Counters list, double-click System.
  5. Select the System Up Time counter.
  6. Click Add.
  7. Click OK.
Tip:
The System Up Time counter displays the uptime in seconds. To convert this value to days, divide it by 86,400 (the number of seconds in a day).

If you prefer a command-line solution, you can use the TYPEPERF utility to display performance counters in a Command Prompt window. Here's the command to run:

typeperf "\system\system up time" -sc 1

The -sc switch specifies the number of samples that you want TYPEPERF to collect and display. We need just one sample in this case.

Displaying Uptime with a Script

The problem with the System Up Time counter (whether you display it in Performance Monitor or at the command line) is that it displays the uptime in seconds, so you have to convert the value (to, say, days) to get a meaningful number. To avoid that, either use Task Manager, instead (which shows the uptime in days, hours, minutes, and seconds) or you can use the script in Listing below, which does the conversion for you.

NOTE:
You can download the scripts in this article from my website at www.mcfedries.com/HomeServerUnleashed3E/.
LISTING: Script That Displays the System Uptime in Days, Hours, and Minutes
Option Explicit
    Dim objOS, dateLastBoot, nSystemUptime
    Dim nDays, nHours, nMinutes
' Get the Windows Home Server OS object
'
For Each objOS in GetObject( _
    "winmgmts:").InstancesOf ("Win32_OperatingSystem")
    '
    ' Return the last boot up time and
    ' convert it to a Date object
    '
    dateLastBoot = ConvertToDate(objOS.LastBootUpTime)
    '
    ' Calculate the number of minutes between then and now
    '
    nSystemUptime = DateDiff("n", dateLastBoot, Now)
    '
    ' Convert the total minutes into hours, days, and minutes
    '
    nDays = Int(nSystemUptime / 1440)
    nHours = Int (((nSystemUptime / 1440) - nDays) * 24)
    nMinutes = nSystemUptime Mod 60
    '
    ' Display the result
    '
    Wscript.Echo "Last Boot: " & dateLastBoot & vbCrLf & _
		"System Uptime: " & _
		nDays & " days and " & _
		nHours & " hours and " & _
		nMinutes & " minutes"
Next
'
' This function takes a datetime string and converts
' it to a real date and time object
'
    Function ConvertToDate(strDate)
    Dim strYear, strMonth, strDay
    Dim strHour, strMinute, strSecond
    strYear = Left(strDate, 4)
    strMonth = Mid(strDate, 5, 2)
    strDay = Mid(strDate, 7, 2)
    strHour = Mid(strDate, 9, 2)
    strMinute = Mid(strDate, 11, 2)
    strSecond = Mid(strDate, 13, 2)
    ConvertToDate = DateSerial(strYear, strMonth, strDay) & " " & _
		TimeSerial(strHour, strMinute, strSecond)
End Function

This script references the Win32_OperatingSystem class, which has just one member object: the Windows Home Server operating system, represented in the For Each...Next loop by objOS. The script gets the LastBootUpTime property and converts the resulting string to a Date object using the ConvertToDate function. DateDiff returns the number of minutes between the last boot and Now. (This difference is the raw value for the system uptime.) Then the script converts the total minutes into the corresponding number of days, hours, and minutes and displays the result.