如何测试程序是否已安装BoxStarter脚本?

时间:2017-03-16 13:05:02

标签: chocolatey boxstarter

是否有任何内置命令可以检查程序是否已经安装,而不是由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
}

0 个答案:

没有答案
相关问题