SEBWIN-446: Ensured missing machine info doesn't result in fatal error during startup.
This commit is contained in:
parent
b8393f2ae5
commit
d2407afebf
1 changed files with 28 additions and 20 deletions
|
@ -53,33 +53,41 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
var model = default(string);
|
var model = default(string);
|
||||||
var systemFamily = default(string);
|
var systemFamily = default(string);
|
||||||
|
|
||||||
using (var searcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem"))
|
try
|
||||||
using (var results = searcher.Get())
|
|
||||||
using (var system = results.Cast<ManagementObject>().First())
|
|
||||||
{
|
{
|
||||||
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<ManagementObject>().First())
|
||||||
{
|
{
|
||||||
if (property.Name.Equals("Manufacturer"))
|
foreach (var property in system.Properties)
|
||||||
{
|
{
|
||||||
Manufacturer = Convert.ToString(property.Value);
|
if (property.Name.Equals("Manufacturer"))
|
||||||
}
|
{
|
||||||
else if (property.Name.Equals("Model"))
|
Manufacturer = Convert.ToString(property.Value);
|
||||||
{
|
}
|
||||||
model = Convert.ToString(property.Value);
|
else if (property.Name.Equals("Model"))
|
||||||
}
|
{
|
||||||
else if (property.Name.Equals("Name"))
|
model = Convert.ToString(property.Value);
|
||||||
{
|
}
|
||||||
Name = Convert.ToString(property.Value);
|
else if (property.Name.Equals("Name"))
|
||||||
}
|
{
|
||||||
else if (property.Name.Equals("SystemFamily"))
|
Name = Convert.ToString(property.Value);
|
||||||
{
|
}
|
||||||
systemFamily = 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()
|
private void InitializeOperatingSystem()
|
||||||
|
|
Loading…
Reference in a new issue