@@ -37,6 +37,28 @@ exit /b
3737#>
3838
3939# ======================== PowerShell ========================
40+ # ======================== Force GamingServicesNet ========================
41+ # Attempt to forcibly remove GamingServicesNet service
42+ $gamingService = 'GamingServicesNet'
43+ $svcRegPath = " HKLM\\SYSTEM\\CurrentControlSet\\Services\\$gamingService"
44+ Write-Host " `n=== Attempting to forcibly remove GamingServicesNet ===" -ForegroundColor Magenta
45+ try {
46+ # Stop the service if running
47+ $svc = Get-Service -Name $gamingService -ErrorAction SilentlyContinue
48+ if ($svc -and $svc.Status -ne 'Stopped') {
49+ Stop-Service -Name $gamingService -Force -ErrorAction SilentlyContinue
50+ Write-Host " Stopped GamingServicesNet." -ForegroundColor Green
51+ }
52+ # Remove service using sc.exe
53+ $null = & cmd.exe /c " sc.exe delete $gamingService"
54+ Write-Host " Issued sc delete command for GamingServicesNet." -ForegroundColor Green
55+ # Remove registry key
56+ $null = & cmd.exe /c " reg.exe delete \" $svcRegPath\" /f"
57+ Write-Host " Deleted registry key for GamingServicesNet." -ForegroundColor Green
58+ } catch {
59+ Write-Host " WARNING: Could not forcibly remove GamingServicesNet: $($_.Exception.Message)" -ForegroundColor Yellow
60+ }
61+
4062
4163Add-Type -MemberDefinition @ "
4264[DllImport(" kernel32.dll" , SetLastError = true)]
@@ -56,7 +78,7 @@ $mode = $mode -band (-bnot 0x0040) # Remove ENABLE_QUICK_EDIT_MODE
5678$Silent = $env:SILENT -eq '1'
5779
5880$TargetFile = 'C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd'
59- $RootServices = @ ('ClipSVC','AppXSvc', 'StateRepository')
81+ $RootServices = @ ('GamingServicesNet', ' ClipSVC','AppXSvc', 'StateRepository')
6082
6183function Get-AllDependents {
6284 param([string]$ServiceName)
@@ -99,6 +121,10 @@ foreach ($root in $RootServices) {
99121 [void]$allServiceNames.Add($dep)
100122 }
101123}
124+ # Remove GamingServicesNet and GamingServices from the list if forcibly handled
125+ $allServiceNames.Remove('GamingServicesNet') | Out-Null
126+ $allServiceNames.Remove('GamingServices') | Out-Null
127+
102128
103129$originalStartTypes = @ {}
104130foreach ($svc in $allServiceNames) {
0 commit comments