4

I'm using wmic to find the current version of an in-house application. My command looks like this:

wmic product where "name='Application Name'" get version

I've never used wmi, but I've read about people saying it's easier to use than wmic. I think my use is a pretty simple one, but how would I use wmi for this, and would it be faster than wmic? (wmic runs very slowly for me)

1
  • 3
    When you use wmic, you are in fact "using wmi". wmic = wmi commandline Dec 10, 2015 at 17:01

4 Answers 4

2

PowerShell

Get-WMIObject -Query "SELECT Version FROM Win32_Product WHERE Name='SomeName'"
2

I've read bad things about using Win32_Product. I don't know the details about it, so maybe it's fine in this case, but I ended up going with the following after reading this blog and asking this question:

$regpath = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$version = Get-ItemProperty "$regpath\*" |
           Where-Object { $_.DisplayName -eq 'Application Name' } |
           Select-Object -Expand DisplayVersion
1
  • 1
    I read that same blog a few months ago and it completely scared me off using the Win32_Product class as well. I would love to hear more remarks regard this "warning" (i.e. use cases, empirical evidence, production experience) regarding the use of the Win32_Product class though, as it seems like people are still using it quite often, and it has never affected any of my systems in the staging and testing environments. Dec 10, 2015 at 15:13
1

To emulate the wmic command you posted using WMI, open a PowerShell prompt and input:

Get-WmiObject -Class "Win32_Product" | Where-Object { $_.Name -eq "Application Name" } | select Name,Version

You can use { $_.Name -like "*application*" } for better matching, if needed.

This can also be run against remote machines and/or using different credentials by adding the -ComputerName and -Credential parameters.

0

Here is a powershell script to get some information about chrome and of course you can change it on the script below :

$OS_Architecture = $env:PROCESSOR_ARCHITECTURE
if($OS_Architecture -eq 'x86')
{$key="HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"} 
    else {$key="HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"}

Get-ItemProperty $Key |
    Where-Object { $_.DisplayName -match 'chrome' } |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
            Format-Table –AutoSize

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .