diff -r 3ad822f418cb -r edb59f3745e8 GUI/StartupManager.cs --- a/GUI/StartupManager.cs Mon Sep 13 22:55:25 2010 +0000 +++ b/GUI/StartupManager.cs Tue Sep 14 19:23:11 2010 +0000 @@ -174,7 +174,7 @@ } private void CreateRegistryRun() { - RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN); + RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN); key.SetValue("OpenHardwareMonitor", Application.ExecutablePath); } @@ -192,20 +192,27 @@ return startup; } set { - if (startup != value) { - startup = value; + if (startup != value) { if (isAvailable) { if (scheduler != null) { - if (startup) + if (value) CreateSchedulerTask(); else DeleteSchedulerTask(); + startup = value; } else { - if (startup) - CreateRegistryRun(); - else - DeleteRegistryRun(); + try { + if (value) + CreateRegistryRun(); + else + DeleteRegistryRun(); + startup = value; + } catch (UnauthorizedAccessException) { + throw new InvalidOperationException(); + } } + } else { + throw new InvalidOperationException(); } } }