diff --git a/trunk/report_templates/SYSTEM_ShutdownTime.qs b/trunk/report_templates/SYSTEM_ShutdownTime.qs
index 1cc3ca0..23ffbe9 100644
--- a/trunk/report_templates/SYSTEM_ShutdownTime.qs
+++ b/trunk/report_templates/SYSTEM_ShutdownTime.qs
@@ -1,32 +1,45 @@
+function IsValid(val) {
+ if(typeof val !== 'undefined') return true;
+ else return false;
+}
+
function print_table_row(cell01,cell02) {
println("
",cell01," | ",cell02," |
");
}
// Global vars
var val;
-// Get current controlset
-var cur_controlset=GetRegistryKeyValue("\\Select","Current");
-cur_controlset=RegistryKeyValueToString(cur_controlset.value,cur_controlset.type);
-// Current holds a DWORD value, thus we get a string like 0x00000000, but
-// control sets are referenced only with the last 3 digits.
-cur_controlset="ControlSet"+String(cur_controlset).substr(7,3);
-
println("");
println(" Last known shutdown time");
println(" ");
println(" Last known shutdown time
");
-println(" ");
-println("
");
-print_table_row("Active control set:",cur_controlset);
+// Get current controlset
+var cur_controlset=GetRegistryKeyValue("\\Select","Current");
+if(IsValid(cur_controlset)) {
+ cur_controlset=RegistryKeyValueToString(cur_controlset.value,cur_controlset.type);
+ // Current holds a DWORD value, thus we get a string like 0x00000000, but
+ // control sets are referenced only with the last 3 digits.
+ cur_controlset="ControlSet"+String(cur_controlset).substr(7,3);
+
+ println(" ");
+ println("
");
-// Shutdown time
-val=GetRegistryKeyValue(cur_controlset+"\\Control\\Windows","ShutdownTime");
-print_table_row("Shutdown time:",RegistryKeyValueToVariant(val.value,"filetime"));
+ print_table_row("Active control set:",cur_controlset);
-println("
");
-println("
");
+ // Shutdown time
+ val=GetRegistryKeyValue(cur_controlset+"\\Control\\Windows","ShutdownTime");
+ print_table_row("Shutdown time:",(IsValid(val)) ? RegistryKeyValueToVariant(val.value,"filetime") : "Unknown");
+
+ println("
");
+ println("
");
+ println(" ");
+} else {
+ println(" ");
+ println(" Unable to determine current control set!
");
+ println(" Are you sure you are running this report against the correct registry hive?");
+ println("
");
+}
-println(" ");
println("");