🟣 C# / .NET 6+

Disable Xbox Game Bar Capture (C#)

Disables background game/app capture via the Xbox Game Bar. Applies the tweak via Microsoft.Win32.Registry.

By WindowsScripting.com · 509 B
SetDisableGameBar.cs
// SetDisableGameBar.cs
//
// Disable Xbox Game Bar Capture.
// Disables background game/app capture via the Xbox Game Bar.
//
// Usage: dotnet new console -o SetDisableGameBar, replace Program.cs with this
// file, then dotnet run.

using System;
using Microsoft.Win32;

using RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\GameDVR");
key.SetValue("AppCaptureEnabled", 0, RegistryValueKind.DWord);

Console.WriteLine("Disable Xbox Game Bar Capture applied.");