Hi Andrew and Ronny,
Andrew, did you locate this key in the registry? ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability\ShutdownReasonUI" )
It does not seem to be a default registered key so you might have to create it yourself. (At least I have not located it on the Windows machines i checked regedit so far)
What Ronny suggested seems like a good way to go. Allthough I can not find the registry key you mentioned in your script Ronny ("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Reliability\ShutdownReasonUI"). Is it OS specific?
On Windows 7, 2008 R2 and Windows 8 I cant seem to find it.
Did find another key though, that seems to be used to log last shutdown reason.
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability\shutdown\ReasonCode"
There seems to be a vast number of reason codes to pick from. You can find the listings here. msdn.microsoft.com/.../aa376885(VS.85).aspx