diff --git a/WarBender.UI/MainForm.cs b/WarBender.UI/MainForm.cs index d10a9bd..44bc09d 100644 --- a/WarBender.UI/MainForm.cs +++ b/WarBender.UI/MainForm.cs @@ -67,9 +67,15 @@ public Game Game { private string WarbandPath { get { - var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); - var warbandKey = hklm.OpenSubKey(@"SOFTWARE\mount&blade warband"); - return warbandKey.GetValue("install_path", null)?.ToString(); + try { + var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); + var warbandKey = hklm?.OpenSubKey(@"SOFTWARE\mount&blade warband"); + return warbandKey?.GetValue("install_path", null)?.ToString(); + } catch (UnauthorizedAccessException) { + return null; + } catch (IOException) { + return null; + } } }