public void putSoftwareList(string filename) { Trace.TraceInformation("Put SoftareList: {0}", this.machineName); SoftwareList sl = getSoftwareList(); sl.ToXML(filename); }
public SoftwareList getSoftwareList() { Trace.TraceInformation("Get SoftareList: {0}", this.machineName); SoftwareList sl = new SoftwareList(); sl.DateStamp = DateTime.Now; sl.MachineName = this.machineName; try { ManagementScope scope = new ManagementScope("\\\\Computer_B\\root\\cimv2"); scope.Connect(); ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Product"); ManagementObjectSearcher products = new ManagementObjectSearcher(scope, query); var result = products.Get(); sl.DateStamp = DateTime.Now; sl.MachineName = this.machineName; foreach (var product in result) { sl.Software.Add(product.GetPropertyValue("Name").ToString()); } Trace.TraceInformation("Softare count: {0}", sl.Software.Count()); } catch (Exception ex) { Trace.TraceError("Error: {0}", ex.Message); throw ex; } return(sl); }