From 68cacfce899366b663e5cbdf73552b4c125d7a99 Mon Sep 17 00:00:00 2001 From: Jeffrey <9938813+Raphire@users.noreply.github.com> Date: Thu, 23 Jul 2026 22:23:00 +0200 Subject: [PATCH] fix: force stop widget processes to prevent prompt (#713) --- Scripts/Features/Invoke-Changes.ps1 | 2 +- Tests/Invoke-Changes.Tests.ps1 | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Scripts/Features/Invoke-Changes.ps1 b/Scripts/Features/Invoke-Changes.ps1 index 1a1de4f..b577065 100644 --- a/Scripts/Features/Invoke-Changes.ps1 +++ b/Scripts/Features/Invoke-Changes.ps1 @@ -73,7 +73,7 @@ function Invoke-FeatureApply { Write-Host "> $applyText..." # Stop widgets related processes before removing the app packages to prevent potential issues if (-not $script:Params.ContainsKey("WhatIf")) { - Get-Process *Widget* -ErrorAction SilentlyContinue | Stop-Process + Get-Process *Widget* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue } Remove-SelectedApps @('Microsoft.StartExperiencesApp','MicrosoftWindows.Client.WebExperience','Microsoft.WidgetsPlatformRuntime') diff --git a/Tests/Invoke-Changes.Tests.ps1 b/Tests/Invoke-Changes.Tests.ps1 index 16019a7..2f61018 100644 --- a/Tests/Invoke-Changes.Tests.ps1 +++ b/Tests/Invoke-Changes.Tests.ps1 @@ -132,6 +132,14 @@ Describe 'Invoke-FeatureApply' { Should -Invoke Stop-Process -Times 0 -Exactly } + It 'stops widget processes without a confirmation prompt' { + Mock Get-Process { [PSCustomObject]@{ Name = 'Widgets' } } + + Invoke-FeatureApply -FeatureId 'DisableWidgets' + + Should -Invoke Stop-Process -Times 1 -Exactly -ParameterFilter { $Force -and $ErrorAction -eq 'SilentlyContinue' } + } + It 'enables the expected optional Windows features' { Invoke-FeatureApply -FeatureId 'EnableWindowsSandbox' Invoke-FeatureApply -FeatureId 'EnableWindowsSubsystemForLinux'