BSOD Command Prompt cscript Linux systeminfo Windows 2008 Windows 7 Windows Vista WMI wmic

Find Last Reboot Time in Windows 7, Vista and Windows 2008

Have you ever wanted a quick and easy way to know how long your Windows 7 (or Vista or Windows 2008 server) system has been running?  When it was last restarted or rebooted?  There are a few easy ways this can be done, most from the Windows command line.  So open a Windows command prompt and choose the one that works best for you.  (Most of these commands work with Windows XP, Windows 2003, 2000, etc.  See notes below for specifics.)

  • This first way will display how long the network service has been running.  Generally this will be very close to the same amount of time (within a minute or two) as Windows has been running.  It won’t be accurate if you restart the network service.
    Note: I listed this first because it’s the one I usually use.

    From a command prompt window run the following (the ‘S’ in ‘Statistics’ must be capitalized):

net statistics workstation | find "Statistics"

You can shortcut it as well using:

net stats work | find "Stat"


Or ever shorter use either of the following:

net stats work
netstats work |more

  • This next method uses the command ‘systeminfo.’  Again from a command prompt run (make sure to capitalize ‘S’, ‘B’ and ‘T’:

systeminfo | find "System Boot Time"


You can use the following on XP, Windows 2003 and earlier (however this will give only the length of uptime and not the system boot time):

systeminfo | find "Up Time"

  • The third method uses WMI, more specifically wmic (Windows Management Instrumentation Command-line), but the output is a little cryptic:

wmic OS Get LastBootUpTime

Result: 20091220133343.981621-300, which can be intrepreted as year 2009, month 12, day 20, hour 13 (or 1:00 PM), minute 33, etc.  Note: be careful as this may be displayed as UTC time depending on your system – like with Amazon EC2 virtual servers for example.

  • You can always use the system event log (this only works on 2003/XP or older).  Of course, you could go to Control Panel and browse through the system event log, but let’s do it through the command line with:

cscript c:windowssystem32eventquery.vbs /fi "ID eq 6005" /l system

Over the years I have found system event log event 6005, “The Event log service was started.” to be the the most consistent entry after a computer restarts, even from a power outage, BSOD or other event.  This command will also give you a history of system startups listed in the System event log.

  • Finally, you can use this handy PowerShell script:
    Get-WmiObject Win32_NTLogEvent -filter "LogFile='System' and EventCode=6005" | Format-Table ComputerName, EventCode, Message, TimeWritten

Just like with anything there are many ways to skin this cat, so choose your favorite one (or two to double-check data) and go for it.

Command Line cscript HTTP Headers IIS Linux Windows

Set IIS 6 (and IIS 7) custom HTTP headers from the command line

Command line method to set the Custom HTTP Headers.
*Must execute from (default) c:InetpubAdminScripts:

cscript adsutil.vbs set w3svc/HttpCustomHeaders “X-Powered-By: ASP.NET” “<Header 2>: <Value 2>” “<Header 3>: <Value 3>”

Just replace “Header 2”: “Value 2” and “Header 3”: “Value 3” with your own values. Add more as desired.

Note: This command updates/replaces current values and does not add to them so any existing value must be included or it will be overwritten. I included “X-Powered-By: ASP.NET” as it’s a common default HTTP header value.

This works on both IIS 6 and IIS 7, not sure about previous versions.

cscript Linux Windows

Running scripts using the command-line-based script host (Cscript.exe)

You can run scripts with the command-line-based script host by typing the following at the command prompt:

cscript [script name] [host options] [script arguments]


script name is the name of the script file, including the file name extension and any necessary path information.
host options are the command-line switches that enable or disable various Windows Script Host features. Host options are always preceded by two slashes (//).
script arguments are the command-line switches that are passed to the script. Script arguments are always preceded by one slash (/).


Each parameter is optional; however, you cannot specify script arguments without specifying a script. If you do not specify a script or any script arguments, Cscript.exe displays the Cscript.exe syntax and the valid host options.
The command-line-based script host supports the following host options:

Parameter Action
Specifies batch mode, which does not display alerts, scripting errors, or input prompts.
Turns on the debugger.
Specifies the scripting language that is used to run the script.
//H:cscript or //H:wscript
Registers either Cscript.exe or Wscript.exe as the default script host for running scripts. If neither is specified, the default is Wscript.exe.
Specifies interactive mode, which displays alerts, scripting errors, and input prompts. This is the default and the opposite of //B.
Runs the job identified by xxxx in a .wsf script file.
Specifies that the Windows Script Host banner is displayed in the console window before the script runs. This is the default and the opposite of //Nologo.
Specifies that the Windows Script Host banner is not displayed before the script runs.
Saves the current command-prompt options for the current user.
Specifies the maximum time the script can run (in seconds). You can specify up to 32,767 seconds. The default is no time limit.
Starts the script in the debugger.
Displays available command parameters and provides help for using them (this is the same as typing Cscript.exe with no parameters and no script).
The time out option (//T:nnnnn) prevents excessive execution of scripts by setting a time limit. When execution time exceeds the specified value, Cscript.exe interrupts the script engine and stops the process.
You can also use Windows Script Host to create .wsf script files, with which you can call multiple scripting engines and perform multiple jobs, all from one file.