Is there an efficient way to query if product is installed on Windows and retrieve IdentifyingNumber

4

I'm trying to automate a test process to first uninstall a product if present.

To find the product I've so far found that the information is available through wmi and wmic product get IdentifyingNumber, name, version | findstr /I /C:"Name" retrieves the info I need.

This query and search takes a long time, but I couldn't seem to get a wmi where clause to work.

Is there something I can do to make this faster?
Or, Is there some other method to get to the IdentifyingNumber?

Greg Domjan

Posted 2015-07-08T20:48:21.187

Reputation: 143

Answers

5

wmic solution using where

This should be faster as you don't need to pipe the output to findstr

wmic product where "name like 'Name'" get IdentifyingNumber, name, version

Example:

To find the information for iTunes

F:\test>wmic product where "name like 'iTunes'" get IdentifyingNumber, name, version
IdentifyingNumber                       Name    Version
{93F2A022-6C37-48B8-B241-FFABD9F60C30}  iTunes  12.1.2.27

Further reading

DavidPostill

Posted 2015-07-08T20:48:21.187

Reputation: 118 938

Thank you. That about halves the time it was taking for me, just under a minute down from 2 minutes - about 5 minutes saved per run. I see how the where clause works now too. – Greg Domjan – 2015-07-08T23:15:35.640

you can also add % in the query to make it more common , "name like '%Skype%'" https://codeslammer.wordpress.com/2009/02/21/wmic-wildcard-search-using-like-and/

– TechDog – 2016-09-19T13:19:56.540