diff --git a/SafeExamBrowser.SystemComponents/SystemInfo.cs b/SafeExamBrowser.SystemComponents/SystemInfo.cs index a91c5db4..2e2b571a 100644 --- a/SafeExamBrowser.SystemComponents/SystemInfo.cs +++ b/SafeExamBrowser.SystemComponents/SystemInfo.cs @@ -53,33 +53,41 @@ namespace SafeExamBrowser.SystemComponents var model = default(string); var systemFamily = default(string); - using (var searcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem")) - using (var results = searcher.Get()) - using (var system = results.Cast().First()) + try { - foreach (var property in system.Properties) + using (var searcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem")) + using (var results = searcher.Get()) + using (var system = results.Cast().First()) { - if (property.Name.Equals("Manufacturer")) + foreach (var property in system.Properties) { - Manufacturer = Convert.ToString(property.Value); - } - else if (property.Name.Equals("Model")) - { - model = Convert.ToString(property.Value); - } - else if (property.Name.Equals("Name")) - { - Name = Convert.ToString(property.Value); - } - else if (property.Name.Equals("SystemFamily")) - { - systemFamily = Convert.ToString(property.Value); + if (property.Name.Equals("Manufacturer")) + { + Manufacturer = Convert.ToString(property.Value); + } + else if (property.Name.Equals("Model")) + { + model = Convert.ToString(property.Value); + } + else if (property.Name.Equals("Name")) + { + Name = Convert.ToString(property.Value); + } + else if (property.Name.Equals("SystemFamily")) + { + systemFamily = Convert.ToString(property.Value); + } } } + Model = string.Join(" ", systemFamily, model); + } + catch (Exception) + { + Manufacturer = ""; + Model = ""; + Name = ""; } - - Model = string.Join(" ", systemFamily, model); } private void InitializeOperatingSystem()