internal static void ReportInstallFlag() { try { bool isWCRegistryExist = false; var key_name = String.Format(@"SOFTWARE\{0}\{1}", Company, Product); int installed = 0; // this should create installed using (RegistryKey parent = Registry.LocalMachine.OpenSubKey(key_name)) { if (parent != null) { var obj = parent.GetValue("Installed"); if (obj != null) { installed = (int)obj; isWCRegistryExist = true; } } } CommunicationUtils.SendReport("reg_check :" + isWCRegistryExist); } catch (System.Exception ex) { CommunicationUtils.SendReport("reg_check :false"); } }
public static void ReportInstalledAntivirus() { bool vista = IsVistaOrHigher(); string wmipathstr = @"\\" + Environment.MachineName + (vista ? @"\root\SecurityCenter2" : @"\root\SecurityCenter"); try { ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct"); ManagementObjectCollection instances = searcher.Get(); if (instances.Count > 0) { foreach (var instance in instances) { String str = String.Empty; if (vista) { var state = Int32.Parse(instance["productState"].ToString()); str = String.Format("Antivirus detected: {0} [{1}]", instance["displayName"], GetAvInfoFromState(state)); } else { str = String.Format("Antivirus detected: {0} [{1}]", instance["displayName"], instance["companyName"]); } CommunicationUtils.SendReport(str); } } else { CommunicationUtils.SendReport("Antivirus not detected"); } } catch (System.Exception e) { CommunicationUtils.SendReport("Antivirus: failed to detect: " + e); Trace.WriteLine(e.Message); } }
internal static void ReportIsMachineVM() { bool isVM = false; using (var searcher = new System.Management.ManagementObjectSearcher("Select * from Win32_ComputerSystem")) { using (var items = searcher.Get()) { foreach (var item in items) { string manufacturer = item["Manufacturer"].ToString().ToLower(); if ((manufacturer == "microsoft corporation" && item["Model"].ToString().ToUpperInvariant().Contains("VIRTUAL")) || manufacturer.Contains("vmware") || item["Model"].ToString() == "VirtualBox") { isVM = true; } } } } CommunicationUtils.SendReport("vm_check " + isVM); }