Skip to content

Commit

Permalink
Merge pull request #43 from elmundio87/windows-package-use-registry
Browse files Browse the repository at this point in the history
Win32_Product call replaced with registry key search
  • Loading branch information
mizzy committed Jan 29, 2014
2 parents 138f911 + 767ad5f commit c683798
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
function FindInstalledApplication
{
param($appName, $appVersion)
$selectionCriteria = "(Name like '$appName' or PackageName like '$appName') and InstallState = 5"
if ($appVersion -ne $null) { $selectionCriteria += " and version = '$appVersion'"}
Get-WmiObject Win32_Product -filter $selectionCriteria
}

if ((Get-WmiObject win32_operatingsystem).OSArchitecture -notlike '64-bit')
{
$keys= (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*')
}
else
{
$keys = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
}

if ($appVersion -eq $null) {
$keys | Where-Object {$_.name -like $appName -or $_.PSChildName -like $appName}
}
else{
$keys | Where-Object {$_.name -like $appName -or $_.PSChildName -like $appName } | Where-Object {$_.DisplayVersion -eq $appVersion}
}
}

0 comments on commit c683798

Please sign in to comment.