SEBWIN-446: Ensured missing machine info doesn't result in fatal error during startup.

This commit is contained in:
Damian Büchel 2020-12-04 13:44:40 +01:00
parent b8393f2ae5
commit d2407afebf

View file

@ -53,6 +53,8 @@ namespace SafeExamBrowser.SystemComponents
var model = default(string);
var systemFamily = default(string);
try
{
using (var searcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem"))
using (var results = searcher.Get())
using (var system = results.Cast<ManagementObject>().First())
@ -76,11 +78,17 @@ namespace SafeExamBrowser.SystemComponents
systemFamily = Convert.ToString(property.Value);
}
}
}
Model = string.Join(" ", systemFamily, model);
}
catch (Exception)
{
Manufacturer = "";
Model = "";
Name = "";
}
}
private void InitializeOperatingSystem()
{