Click here to Skip to main content
15,898,373 members
Home / Discussions / C#
   

C#

 
QuestionRe: C# Help Pin
jojoba201110-Apr-10 18:21
jojoba201110-Apr-10 18:21 
AnswerRe: C# Help Pin
PIEBALDconsult10-Apr-10 19:07
mvePIEBALDconsult10-Apr-10 19:07 
AnswerRe: C# Help Pin
Jens Meyer10-Apr-10 19:18
Jens Meyer10-Apr-10 19:18 
AnswerRe: C# Help Pin
Eddy Vluggen10-Apr-10 22:37
professionalEddy Vluggen10-Apr-10 22:37 
GeneralRe: C# Help Pin
PIEBALDconsult11-Apr-10 4:29
mvePIEBALDconsult11-Apr-10 4:29 
GeneralRe: C# Help Pin
Eddy Vluggen11-Apr-10 5:00
professionalEddy Vluggen11-Apr-10 5:00 
AnswerRe: C# Help Pin
Ravi Bhavnani10-Apr-10 23:09
professionalRavi Bhavnani10-Apr-10 23:09 
QuestionWMI Win32_Product speed.... Pin
Jacob Dixon10-Apr-10 16:36
Jacob Dixon10-Apr-10 16:36 
Hello there! I am "successfully" using WMI to get a list of products from any computer that can be accessed remotely. I understand that it only shows products that were installed using a MSI file.

What I would like is to list products installed (MSI, EXE, or whatever... not just MSI). Another thing I had to ask was if there was a better way to doing this? You might suggest reading the registry, but the problem is the computers that this application will run on is x86 and the servers are x64. So you can't read a x64 registry from a x86.

Does anyone have a better solution that will increase the speed and also show ALL products? I have read there really isn't a way to speed up WMI when getting a list of products.. just the way it is designed.

In case you want to see code:
public List<Product> InstalledApplications(string dns)
{
    List<Product> products = new List<Product>();
    try
    {
        ManagementScope scope = new ManagementScope(@"\\" + dns + @"\root\CIMV2", conn);
        ManagementObjectSearcher mos = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT Name, Vendor, InstallLocation, InstallDate2, Version FROM Win32_Product"));

        foreach (ManagementObject mo in mos.Get())
        {
            if (mo["Name"] != null)
            {
                Product product = new Product();
                product.Name = mo["Name"].ToString().Trim();

                if (mo["Vendor"] != null)
                    product.Vendor = mo["Vendor"].ToString().Trim();

                if (mo["InstallLocation"] != null)
                    product.InstallLocation = mo["InstallLocation"].ToString().Trim();

                if (mo["InstallDate2"] != null)
                    product.InstallDate2 = ParseCIMDateTime(mo["InstallDate2"].ToString());

                if (mo["Version"] != null)
                    product.Version = mo["Version"].ToString().Trim();

                products.Add(product);
            }
        }
    }
    catch (ThreadAbortException) {  }
    catch (Exception ex) {
        EventLog.WriteEntry("ADEM Application", ex.Message, EventLogEntryType.Error);

        Product product = new Product();
        product.Name    = "Error";
        product.Vendor  = ex.Source;
        product.InstallLocation = ex.ToString();
        products.Add(product);
    }

    return products;
}

AnswerRe: WMI Win32_Product speed.... Pin
Dan Mos10-Apr-10 20:09
Dan Mos10-Apr-10 20:09 
AnswerRe: WMI Win32_Product speed.... Pin
Eddy Vluggen10-Apr-10 22:29
professionalEddy Vluggen10-Apr-10 22:29 
GeneralRe: WMI Win32_Product speed.... Pin
Jacob Dixon11-Apr-10 5:05
Jacob Dixon11-Apr-10 5:05 
GeneralRe: WMI Win32_Product speed.... Pin
Eddy Vluggen11-Apr-10 5:15
professionalEddy Vluggen11-Apr-10 5:15 
GeneralRe: WMI Win32_Product speed.... Pin
Jacob Dixon11-Apr-10 5:18
Jacob Dixon11-Apr-10 5:18 
GeneralRe: WMI Win32_Product speed.... Pin
Eddy Vluggen11-Apr-10 5:24
professionalEddy Vluggen11-Apr-10 5:24 
AnswerRe: WMI Win32_Product speed.... Pin
Moreno Airoldi10-Apr-10 22:37
Moreno Airoldi10-Apr-10 22:37 
GeneralRe: WMI Win32_Product speed.... Pin
Jacob Dixon11-Apr-10 5:07
Jacob Dixon11-Apr-10 5:07 
GeneralRe: WMI Win32_Product speed.... Pin
harold aptroot11-Apr-10 10:41
harold aptroot11-Apr-10 10:41 
GeneralRe: WMI Win32_Product speed.... Pin
Jacob Dixon11-Apr-10 12:11
Jacob Dixon11-Apr-10 12:11 
NewsWhirlwind Screencasts Explore New Features in C#4 Pin
brucedkyle10-Apr-10 13:10
brucedkyle10-Apr-10 13:10 
GeneralRe: Whirlwind Screencasts Explore New Features in C#4 Pin
Not Active10-Apr-10 14:48
mentorNot Active10-Apr-10 14:48 
GeneralRe: Whirlwind Screencasts Explore New Features in C#4 Pin
Mycroft Holmes10-Apr-10 21:58
professionalMycroft Holmes10-Apr-10 21:58 
QuestionUsing inline code/macros Pin
Trollslayer10-Apr-10 11:19
mentorTrollslayer10-Apr-10 11:19 
AnswerRe: Using inline code/macros Pin
Not Active10-Apr-10 11:25
mentorNot Active10-Apr-10 11:25 
GeneralRe: Using inline code/macros Pin
Trollslayer10-Apr-10 11:42
mentorTrollslayer10-Apr-10 11:42 
GeneralRe: Using inline code/macros Pin
harold aptroot10-Apr-10 12:03
harold aptroot10-Apr-10 12:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.