5

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
  • 153
  • 1
  • 1
  • 4

1 Answers1

6

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
  • 153,128
  • 77
  • 353
  • 394
  • 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 Jul 08 '15 at 23:15
  • 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 Sep 19 '16 at 13:19