2

Is there any built-in command to check if a program is already installed, but not by Chocolatey?

function Get-InstalledApps {
    if ([IntPtr]::Size -eq 4) {
        $regpath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
    }
    else {
        $regpath = @(
            'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
            'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
        )
    }
    Get-ItemProperty $regpath | .{process{if($_.DisplayName -and $_.UninstallString) { $_ } }} | Select DisplayName, Publisher, InstallDate, DisplayVersion, UninstallString |Sort DisplayName
}

function Is-App-Installed($appName) {
    $appToMatch = "*" + $appName + "*"
    $result = Get-InstalledApps | where {$_.DisplayName -like $appToMatch}
    return $result
}
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
Adrian Halid
  • 589
  • 8
  • 17
  • Nothing currently built in, no. Would some of the licensed features help in what you are trying to achieve? https://chocolatey.org/docs/features-synchronize – Gary Ewan Park Mar 17 '17 at 10:49
  • Chocolatey will be able to this natively in the future. Right now on the business edition, there is `choco sync`. – ferventcoder Mar 17 '17 at 15:15
  • Will have to look at the business features. I think the sync option will be good once the software has been installed. The issue I had was with adobe reader package. Adobe Reader was already installed on the machine and choco install was returning an error code that it was already installed. I guess you could capture that error code as a success. – Adrian Halid Mar 18 '17 at 00:16

0 Answers0