Skip to content

Commit 68cacfc

Browse files
authored
fix: force stop widget processes to prevent prompt (#713)
1 parent a9c1736 commit 68cacfc

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Scripts/Features/Invoke-Changes.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function Invoke-FeatureApply {
7373
Write-Host "> $applyText..."
7474
# Stop widgets related processes before removing the app packages to prevent potential issues
7575
if (-not $script:Params.ContainsKey("WhatIf")) {
76-
Get-Process *Widget* -ErrorAction SilentlyContinue | Stop-Process
76+
Get-Process *Widget* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
7777
}
7878

7979
Remove-SelectedApps @('Microsoft.StartExperiencesApp','MicrosoftWindows.Client.WebExperience','Microsoft.WidgetsPlatformRuntime')

Tests/Invoke-Changes.Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ Describe 'Invoke-FeatureApply' {
132132
Should -Invoke Stop-Process -Times 0 -Exactly
133133
}
134134

135+
It 'stops widget processes without a confirmation prompt' {
136+
Mock Get-Process { [PSCustomObject]@{ Name = 'Widgets' } }
137+
138+
Invoke-FeatureApply -FeatureId 'DisableWidgets'
139+
140+
Should -Invoke Stop-Process -Times 1 -Exactly -ParameterFilter { $Force -and $ErrorAction -eq 'SilentlyContinue' }
141+
}
142+
135143
It 'enables the expected optional Windows features' {
136144
Invoke-FeatureApply -FeatureId 'EnableWindowsSandbox'
137145
Invoke-FeatureApply -FeatureId 'EnableWindowsSubsystemForLinux'

0 commit comments

Comments
 (0)