0

Is there any way (in C#, using WMI classes) to find out that how many times a particular software has been installed and uninstalled?

I want to run it on remote computer. I am getting software list by following code:

ManagementScope scope = new ManagementScope(@"\\" + ipAddress + @"\root\cimv2");
ObjectQuery query = new ObjectQuery("Select * from  Win32_Product");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
    Console.Write(m["Caption"]+"\t");
    Console.WriteLine(m["installDate"]);
}
Adam
  • 15,537
  • 2
  • 42
  • 63
Mohammad Arshad Alam
  • 9,694
  • 6
  • 38
  • 61

1 Answers1

1

Normally not.

When a program will be uninstalled every bit of the program should be removed from the machine like it was never their. Unfortunately nearly every program doesn't make a perfect job at this point leaving some artifacts on the machine.

Nevertheless the desired behavior is that after a uninstall everything is gone (including some kind of counter) so that it is only possible to check if a program is currently installed or not.

On the other site nothing permits a program to save somewhere some counter (e.g. registry) which will increased everytime a installation is started, but that's something specific for each program and no common mechanism exists where this counter should reside.

Oliver
  • 43,366
  • 8
  • 94
  • 151