🟣 C# / .NET 6+

Disable Background Apps Globally (C#)

Prevents Store apps from running in the background to save resources and battery. Applies the tweak via Microsoft.Win32.Registry.

By WindowsScripting.com · 573 B
SetDisableBackgroundApps.cs
// SetDisableBackgroundApps.cs
//
// Disable Background Apps Globally.
// Prevents Store apps from running in the background to save resources and battery.
//
// Usage: dotnet new console -o SetDisableBackgroundApps, replace Program.cs with this
// file, then dotnet run.

using System;
using Microsoft.Win32;

using RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications");
key.SetValue("GlobalUserDisabled", 1, RegistryValueKind.DWord);

Console.WriteLine("Disable Background Apps Globally applied.");