Skip to content

Commit 53e6c0c

Browse files
authored
Add admin check to uninstall of machine font (microsoft#5779)
<!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> Fixes microsoft#5774 Adds an admin check to the font uninstall flow. Non-elevated uninstall of machine font <img width="585" height="63" alt="image" src="https://github.com/user-attachments/assets/e02bea39-8e88-42fc-9355-7b90b875e44a" /> Elevated uninstall of machine font <img width="517" height="53" alt="image" src="https://github.com/user-attachments/assets/d22d502f-64d2-4f4e-8bed-6a8f8ada9071" /> Tested: * Uninstall of machine installed font succeeds from elevated command prompt. * Uninstall of machine font from non-elevated command prompt fails. No release note update required for this, fixes a bug in unreleased code. - [x] I have signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs). - [x] I have updated the [Release Notes](../doc/ReleaseNotes.md). - [x] This pull request is related to an issue. ----- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5779)
1 parent 79e40bf commit 53e6c0c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/AppInstallerCLICore/Workflows/FontFlow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ namespace AppInstaller::CLI::Workflow
315315
fontContext.Scope = scope;
316316
}
317317

318+
if (fontContext.Scope == Manifest::ScopeEnum::Machine && !Runtime::IsRunningAsAdmin())
319+
{
320+
context.Reporter.Error() << Resource::String::CommandRequiresAdmin << std::endl;
321+
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_COMMAND_REQUIRES_ADMIN);
322+
}
323+
318324
auto uninstallResult = Fonts::UninstallFontPackage(fontContext);
319325
if (uninstallResult.Result() != FontResult::Success)
320326
{

0 commit comments

Comments
 (0)