public static SystemState GetSystemState(ManagementScope scope, ManagementScope defaultScope, string serverName, ILogger logger) { SystemState systemState = new SystemState(); try { systemState.RAM = CUtils.RoundUp(WMIUtils.GetRAM(scope) / 1048576L); systemState.CPUs = WMIUtils.GetNumberOfCPUs(scope); WMIUtils.GetOperatingSystemInfo(scope, ref systemState.OsInfo, ref systemState.SystemPath, ref systemState.SystemVolume); try { string str = CUtils.PathToUNC(serverName, systemState.SystemPath) + "\\System32\\hal.dll"; if (File.Exists(str)) { FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(str); systemState.HalInternalName = versionInfo.InternalName; systemState.HalVersion = versionInfo.FileVersion; } } catch (Exception ex) { if (logger != null) { logger.Verbose("Could not get Hal information. Exception: " + ex.Message, "SystemState"); } throw; } try { systemState.ProgramFilesPath = WMIUtils.GetRemoteRegistryValueString(defaultScope, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProgramFilesDir"); } catch (Exception ex) { if (logger != null) { logger.Verbose("Could not get \"Program Files\" path. Exception: " + ex.Message, "SystemState"); } throw; } try { systemState.NetworkAdapters = SystemStateReader.GetNetworkAdapterList(scope); } catch (Exception ex) { if (logger != null) { logger.Verbose("Could not get the logical network adpater info from " + serverName + ". Exception: " + ex.Message, "SystemState"); } throw; } try { systemState.Volumes = SystemStateReader.GetVolumes(scope); } catch (Exception ex) { if (logger != null) { logger.Verbose("Could not get the volume info from " + serverName + ". Exception: " + ex.Message, "SystemState"); } throw; } } catch (Exception ex) { if (logger != null) { logger.Verbose("Exception thrown getting the system state for server " + serverName + ". Exception: " + ex.Message, "SystemState"); } throw; } return(systemState); }