|
4 | 4 | using Flow.Launcher.Helper;
|
5 | 5 | using Flow.Launcher.Infrastructure;
|
6 | 6 | using Flow.Launcher.Infrastructure.Hotkey;
|
| 7 | +using Flow.Launcher.Infrastructure.Logger; |
7 | 8 | using Flow.Launcher.Infrastructure.UserSettings;
|
8 | 9 | using Flow.Launcher.Plugin;
|
9 | 10 | using Flow.Launcher.Plugin.SharedCommands;
|
@@ -70,24 +71,43 @@ private void OnAutoStartupUncheck(object sender, RoutedEventArgs e)
|
70 | 71 |
|
71 | 72 | public static void SetStartup()
|
72 | 73 | {
|
73 |
| - using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); |
74 |
| - key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath); |
| 74 | + try |
| 75 | + { |
| 76 | + using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); |
| 77 | + key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath); |
| 78 | + } |
| 79 | + catch (Exception e) |
| 80 | + { |
| 81 | + Log.Error("SettingsWindow", $"Ignoring non-critical registry error (user permissions?): {e}"); |
| 82 | + } |
75 | 83 | }
|
76 | 84 |
|
77 | 85 | private void RemoveStartup()
|
78 | 86 | {
|
79 |
| - using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); |
80 |
| - key?.DeleteValue(Constant.FlowLauncher, false); |
| 87 | + try |
| 88 | + { |
| 89 | + using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); |
| 90 | + key?.DeleteValue(Constant.FlowLauncher, false); |
| 91 | + } |
| 92 | + catch (Exception e) |
| 93 | + { |
| 94 | + Log.Error("SettingsWindow", $"Ignoring non-critical registry error (user permissions?): {e}"); |
| 95 | + } |
81 | 96 | }
|
82 | 97 |
|
83 | 98 | public static bool StartupSet()
|
84 | 99 | {
|
85 |
| - using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); |
86 |
| - var path = key?.GetValue(Constant.FlowLauncher) as string; |
87 |
| - if (path != null) |
| 100 | + try |
88 | 101 | {
|
| 102 | + using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); |
| 103 | + var path = key?.GetValue(Constant.FlowLauncher) as string; |
89 | 104 | return path == Constant.ExecutablePath;
|
90 | 105 | }
|
| 106 | + catch (Exception e) |
| 107 | + { |
| 108 | + Log.Error("SettingsWindow", $"Ignoring non-critical registry error (user permissions?): {e}"); |
| 109 | + } |
| 110 | + |
91 | 111 | return false;
|
92 | 112 | }
|
93 | 113 |
|
|
0 commit comments