Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Uninstalling the SecHealthUI fails, despite the app being installed. #195

Closed
haiku-balls opened this issue Jan 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@haiku-balls
Copy link

Description

When toggling the Uninstall Windows Store Apps > Uninstall Sys. Apps > People Hub > Windows Security GUI (Sec Health UI) App, it reports 'Not Installed' despite the app being there. The reason is the app isn't "Microsoft.Windows.SecHealthUI" it's "Microsoft.SecHealthUI". I'm not entirely sure if it's due to me using a development build.
image
image

OS

Windows 22H2 (Build 25276.1; Dev)

Reproduction steps

Toggle the option. Run the script with that option, reports 'not installed'.

Scripts

@echo off
:: https://privacy.sexy — v0.11.4 — Thu, 19 Jan 2023 22:59:05 GMT
:: Ensure admin privileges
fltmc >nul 2>&1 || (
    echo Administrator privileges are required.
    PowerShell Start -Verb RunAs '%0' 2> nul || (
        echo Right-click on the script and select "Run as administrator".
        pause & exit 1
    )
    exit 0
)


:: ----------------------------------------------------------
:: ---------Windows Security GUI (Sec Health UI) app---------
:: ----------------------------------------------------------
echo --- Windows Security GUI (Sec Health UI) app
PowerShell -ExecutionPolicy Unrestricted -Command "$package = Get-AppxPackage -AllUsers 'Microsoft.Windows.SecHealthUI'; if (!$package) {; Write-Host 'Not installed'; exit 0; }; $directories = @($package.InstallLocation, "^""$env:LOCALAPPDATA\Packages\$($package.PackageFamilyName)"^""); foreach($dir in $directories) {; if ( !$dir -Or !(Test-Path "^""$dir"^"") ) { continue }; cmd /c ('takeown /f "^""' + $dir + '"^"" /r /d y 1> nul'); if($LASTEXITCODE) { throw 'Failed to take ownership' }; cmd /c ('icacls "^""' + $dir + '"^"" /grant administrators:F /t 1> nul'); if($LASTEXITCODE) { throw 'Failed to take ownership' }; $files = Get-ChildItem -File -Path $dir -Recurse -Force; foreach($file in $files) {; if($file.Name.EndsWith('.OLD')) { continue }; $newName =  $file.FullName + '.OLD'; Write-Host "^""Rename '$($file.FullName)' to '$newName'"^""; Move-Item -LiteralPath "^""$($file.FullName)"^"" -Destination "^""$newName"^"" -Force; }; }"
:: ----------------------------------------------------------


pause
exit /b 0

@haiku-balls haiku-balls added the bug Something isn't working label Jan 19, 2023
@undergroundwires
Copy link
Owner

Hi @haiku-balls,thank you for the quality issue with all context and good suggestion. I will fix this in a patch release soon.

I looked for official sources and did tests to see these service statuses.

Here are my results:

Service Name Sources from Microsoft Existence (Windows 10 21H2) Existence (Windows 11 21H2)
Microsoft.Windows.SecHealthUI Services CSV file microsoft.com ✅ Exists ❌ Missing
Microsoft.SecHealthUI Windows Security Update - Microsoft Support ❌ Missing ✅ Exists

So Microsoft.SecHealthUI seems to be Windows 11 equivalent of the Microsoft.Windows.SecHealthUI.

As we have official documentation for both services, the script should attempt to uninstall both services with some special logic:

  • Delete Microsoft.SecHealthUI on Windows 11 only.
  • Delete Microsoft.Windows.SecHealthUI on Windows 10 only.

undergroundwires added a commit that referenced this issue Dec 5, 2023
This commit fixes the issue of Windows Security app not being removed in
Windows 11. It addresses the problem by extending the app uninstallation
process to cover the new app package specific to Windows 11. It improves
the overall design of templated functions for store app removal to
implement the fix.

- Improve Windows Security removal script:
  - Add support for removing `Microsoft.SecHealthUI` in Windows 11.
  - Revise script documentation for clarity and correct typos.
- Redesign uninstallion of Store apps:
  - Change `UninstallSystemApp` to `UninstallNonRemovableStoreApp` for
    wider usage. This change is due to `Microsoft.SecHealthUI` being
    non-removable yet not a system app.
  - Refactor app data cleanup into two distinct functions
    (`ClearStoreAppDataBeforeUninstallation` and
    `ClearStoreAppDataAfterUninstallation`) for better clarity and
    maintainability. This also helps in testing by allowing easier
    reordering of operations.
  - Seperate between simple non-removable app uninstallation and
    uninstallation with cleanup in separate functions, highlighting that
    the latter is more invasive and should be used cautiously. This
    addresses permission issues encountered with `SecHealthUI` app
    removal during cleanup on Windows 11.
  - Separate uninstalling app and uninstalling app with cleanup to
    different functions, document that cleanup should no longer be
    prefered as it's invasive and too aggresive. Cleanup logic
    introduces permission issues/errors for `SecHealthUI` in Windows 11.
  - Extend app soft-deletion to include the default Windows app folder,
    this ensures that the cleanup covers any kind of Store apps (not
    only system apps).
@undergroundwires
Copy link
Owner

Windows 11 app removal is added in 0.12.9 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants