builtbybel / Winpilot

The manic cousin of Microsoft Copilot
https://builtbybel.com/blog/bloatynosy-is-now-winpilot
MIT License
4.79k stars 149 forks source link

HP Bloatware comes back and BloatyNosy misses it, #92

Closed fasteddys closed 6 months ago

fasteddys commented 1 year ago

Hello, nice work, can you please remove bloat ware HPCaaSClientLib.dll , it keeps reinstalling itself everytime.

Issue:

  • [] BloatyNosy finds the HP bloatware first time under user account, but then fails to remove it under user (since the user does not have admin). However, when you run it second time it does not find it!!!
  • [] analyze/run it 2nd time after it fails due to lack of permission, and it fails to find it.

https://community.spiceworks.com/topic/2310773-remove-all-hp-apps

C:\WINDOWS\System32\DriverStore\FileRepository\hpanalyticscomp.inf_amd64_43 ......\x64\HPCaaSClientLib.dll


$apps = @(
    # HP Bloatware
    "HP Connection Optimizer"
    "HP Documentation"
    "HP Notifications"
    "HP Security Update Service"
    "HP Sure Recover"
    "HP Sure Run Module"
    "HP Wolf Security - Console"
    "HP Wolf Security"

    "AD2F1837.HPEasyClean"
    "AD2F1837.HPPCHardwareDiagnosticsWindows"
    "AD2F1837.HPPowerManager"
    "AD2F1837.HPPrivacySettings"
    "AD2F1837.HPQuickDrop"
    "AD2F1837.HPSupportAssistant"
    "AD2F1837.HPSystemInformation"
    "AD2F1837.myHP"
)
# used for uninstall of HP Connection Optimizer 
# check out this for more info https://gist.github.com/mark05e/a79221b4245962a477a49eb281d97388
$ConnOpt = "[InstallShield Silent]
Version=v7.00
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-DlgOrder]
Dlg0={6468C4A5-E47E-405F-B675-A70A70983EA6}-SdWelcomeMaint-0
Count=3
Dlg1={6468C4A5-E47E-405F-B675-A70A70983EA6}-MessageBox-0
Dlg2={6468C4A5-E47E-405F-B675-A70A70983EA6}-SdFinishReboot-0
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-SdWelcomeMaint-0]
Result=303
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-MessageBox-0]
Result=6
[Application]
Name=HP Connection Optimizer
Version=2.0.18.0
Company=HP Inc.
Lang=0409
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-SdFinishReboot-0]
Result=1
BootOption=0"

$appxprovisionedpackages = Get-AppxProvisionedPackage -Online

foreach ($app in $apps) {
    Write-Output "Trying to remove $app"

    # remove appx packages
    if ((Get-AppxPackage -AllUsers).Name -eq "$app") {
        Get-AppxPackage $app -AllUsers | Remove-AppxPackage -AllUsers | Out-Null
        if ($?) {
            Write-Host "    Successfully removed AppX-Package $app"
            Continue
        } else {
            Write-Host "    Failed to remove AppX-Package $app"
            Continue
        }

        ($appxprovisionedpackages).Where( {$_.DisplayName -EQ $app}) |
            Remove-AppxProvisionedPackage -Online
        if (!$?) {
            Write-Host "    Failed to remove AppX-ProvisionedPackage $app"
        } else {
            Write-Host "    Removed AppX-ProvisionedPackage $app"
        }
        Continue
    }

    # remove normal packages
    Get-Package -Name $app -ErrorAction SilentlyContinue | Out-Null
    if ($?) {
        Uninstall-Package -Name $app -AllVersions -Force
        if (!$?) {
            Write-Host "Failed to remove $app"
        } else {
            # in some cases uninstall command returns a successfull but doesnt actually uninstall the Package
            # https://github.com/OneGet/oneget/issues/435
            # as a last effort i try to remove the Package using the UninstallString
            Get-Package -Name $item -ErrorAction SilentlyContinue | Out-Null
            if ($?) {
                Write-Host "    Couldn't remove Package due to bug. Trying via Uninstallstring..."
                # remove Programms via uninstallString because Remove-Package doesnt work :(
                if ($app -eq "HP Documentation") {
                    try {
                        $uninstallString = "C:\Program Files\HP\Documentation\Doc_uninstall.cmd"
                        Start-Process -FilePath "$uninstallString" -NoNewWindow
                        Write-Host "    Successfully removed HP Documentation via uninstall string"
                    } catch {
                        Write-Host "    Failed to remove HP Documentation via uninstall string"
                    }
                } elseif ($app -eq "HP Connection Optimizer") {
                    try {
                        $ConnOpt | Out-File c:\Windows\Temp\ISS-HP.iss
                        &'C:\Program Files (x86)\InstallShield Installation Information\{6468C4A5-E47E-405F-B675-A70A70983EA6}\setup.exe' @('-s', '-f1C:\Windows\Temp\ISS-HP.iss')

                        Write-Host "    Successfully removed HP Connection Optimizer via uninstallfile"
                    } catch {
                        Write-Host "    Couldnt create uninstallfile for HP Connection Optimizer"
                    }
                }
            }   
        }
    }
}
Belim commented 1 year ago

Thanks, I will take that into account in the upcoming major update.

Belim commented 6 months ago

Winpilot now takes over the legacy of Bloatynosy. The bloatware detection and removal are generations stronger and smarter, so I would recommend you to test this new Bloatynosy 3.0 or now Winpilot 3.0