469,619 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,619 developers. It's quick & easy.

How to programmatically check for versions of software

What are some good ways to programmatically check for software already
installed on a computer?

For example, to check a version of Internet Explorer, a program can check
the registry for the following value:
[HKLM\SOFTWARE\Microsoft\Internet Explorer] Version, and see if the version
is 6.0 or not.

However, not all installed software can be checked as easily. For example,
Windows Media Player 9 has the following registry path:
[HKLM\SOFTWARE\Microsoft\MediaPlayer\9.0\Registrati on] UDBVersion, which one
can use to see which version of WMP9 is installed. However, when version 10
does come out, one does not really know if it will use the same pattern for
registry path.

The biggest problem, perhaps, is that registry paths remain in the registry
even after a program is uninstalled. For example, one may want to check if
a program is installed simply by checking for the existence of a registry
path. But sometimes, uninstalling a program WILL NOT remove the registry
entries, and so, the program will incorrectly believe the software is
already installed.

Maybe my approach is wrong. Perhaps relying on the registry is not 100%
proof. Please suggest better ways for programmatically checking for
versions of software installed on a computer. Thanks.

Nov 16 '05 #1
2 7941
Jak Sparrow wrote:
What are some good ways to programmatically check for software already
installed on a computer?

For example, to check a version of Internet Explorer, a program can check
the registry for the following value:
[HKLM\SOFTWARE\Microsoft\Internet Explorer] Version, and see if the version
is 6.0 or not.

However, not all installed software can be checked as easily. For example,
Windows Media Player 9 has the following registry path:
[HKLM\SOFTWARE\Microsoft\MediaPlayer\9.0\Registrati on] UDBVersion, which one
can use to see which version of WMP9 is installed. However, when version 10
does come out, one does not really know if it will use the same pattern for
registry path.

The biggest problem, perhaps, is that registry paths remain in the registry
even after a program is uninstalled. For example, one may want to check if
a program is installed simply by checking for the existence of a registry
path. But sometimes, uninstalling a program WILL NOT remove the registry
entries, and so, the program will incorrectly believe the software is
already installed.

Maybe my approach is wrong. Perhaps relying on the registry is not 100%
proof. Please suggest better ways for programmatically checking for
versions of software installed on a computer. Thanks.


If you look at the file properties in Windows Explorer, you will see
that each file has a version attribute attached to it.

So

(a) Find the actual executable
(b) Use the File or FileInfo class to read the version attribute.
Nov 16 '05 #2
Hi Jak,

"Jak Sparrow" <no@spam.net> wrote in message
news:up**************@TK2MSFTNGP11.phx.gbl...
What are some good ways to programmatically check for software already
installed on a computer?

<snip>

WMI (System.Management namespace) is a good tool for this sort of task.
Just to give you an idea:

...
// need a "using System.Management;" somewhere
// and a reference to System.Management.dll
static void ListAllProducts()
{
SelectQuery allProductsQuery = new SelectQuery("Win32_Product");

ManagementObjectSearcher allProducts =
new ManagementObjectSearcher(allProductsQuery);

foreach(ManagementObject product in allProducts.Get())
{
Console.WriteLine("Product {0} is at version {1}",
product.Properties["Name"].Value,
product.Properties["Version"].Value);
}
}
...

Regards,
Daniel
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Maxwell2006 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.