GUI/StartupManager.cs
changeset 139 9611b4d9d898
parent 129 efb1b414d33e
child 142 48e487749709
     1.1 --- a/GUI/StartupManager.cs	Tue Jun 08 21:07:13 2010 +0000
     1.2 +++ b/GUI/StartupManager.cs	Sat Jun 12 12:15:00 2010 +0000
     1.3 @@ -38,6 +38,7 @@
     1.4  using System;
     1.5  using System.Collections.Generic;
     1.6  using System.IO;
     1.7 +using System.Runtime.InteropServices;
     1.8  using System.Security.Principal;
     1.9  using System.Windows.Forms;
    1.10  using Microsoft.Win32;
    1.11 @@ -73,6 +74,9 @@
    1.12  
    1.13          if (scheduler != null) {
    1.14            try {
    1.15 +            // check if the taskscheduler is running
    1.16 +            IRunningTaskCollection collection = scheduler.GetRunningTasks(0);            
    1.17 +
    1.18              ITaskFolder folder = scheduler.GetFolder("\\Open Hardware Monitor");
    1.19              IRegisteredTask task = folder.GetTask("Startup");
    1.20              startup = (task != null) && 
    1.21 @@ -90,6 +94,8 @@
    1.22              startup = false;
    1.23            } catch (UnauthorizedAccessException) {
    1.24              scheduler = null;
    1.25 +          } catch (COMException) {
    1.26 +            scheduler = null;
    1.27            }
    1.28          } 
    1.29        } else {