Powershell 解决Win11系统 WIN+G 录屏"目前无法执行录制,请稍后再试"的问题
# 运行此脚本前,请确保以管理员身份运行 PowerShell
# 定义注册表路径
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR"
# 检查 GameDVR 键是否存在,如果不存在则创建
if (-Not (Test-Path $registryPath)) {
New-Item -Path $registryPath -Force | Out-Null
}
# 定义要设置的注册表项
$regItems = @(
# 设置注册表项的值,格式为:键名, 类型, 值
@{ Name = "AllowSoftwareEncode"; Type = "DWORD"; Value = 1 },
@{ Name = "AppCaptureEnabled"; Type = "DWORD"; Value = 1 },
@{ Name = "AudioCaptureEnabled"; Type = "DWORD"; Value = 1 },
@{ Name = "AudioEncodingBitrate"; Type = "DWORD"; Value = 0x0002ee00 },
@{ Name = "CustomVideoEncodingBitrate"; Type = "DWORD"; Value = 0x003d0900 },
@{ Name = "CustomVideoEncodingHeight"; Type = "DWORD"; Value = 0x000002d0 },
@{ Name = "CustomVideoEncodingWidth"; Type = "DWORD"; Value = 0x00000500 },
@{ Name = "ForceSoftwareMFT"; Type = "DWORD"; Value = 1 },
@{ Name = "HistoricalBufferLength"; Type = "DWORD"; Value = 0x0000000f },
@{ Name = "HistoricalCaptureOnBatteryAllowed"; Type = "DWORD"; Value = 1 },
@{ Name = "HistoricalCaptureOnWirelessDisplayAllowed"; Type = "DWORD"; Value = 1 },
@{ Name = "KGLRevision"; Type = "DWORD"; Value = 0x0000099c },
@{ Name = "KGLToGCUpdatedRevision"; Type = "DWORD"; Value = 0x0000099c },
@{ Name = "VideoEncodingBitrateMode"; Type = "DWORD"; Value = 0 }
)
# 设置每个注册表项
foreach ($item in $regItems) {
$name = $item.Name
$type = $item.Type
$value = $item.Value
# 尝试获取现有值
$existingValue = Get-ItemProperty -Path $registryPath -Name $name -ErrorAction SilentlyContinue
if ($existingValue) {
# 如果键值存在,则更新其值
Set-ItemProperty -Path $registryPath -Name $name -Value $value -Type $type
Write-Host "更新键值: $name = $value"
} else {
# 如果键值不存在,则创建它
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType $type -Force
Write-Host "创建键值: $name = $value"
}
}
Write-Host "注册表项设置完成。"
Win10及以上系统自带的 XBox Game Bar 视频录制,按 win+g 选择捕获,按开始录制(win+alt+r),出现目前无法执行录制,请稍后再试。则可以考虑用上面的方法设置注册表项,从而解决问题。
如果要更改录制的分辨率为1920*1080,则 "CustomVideoEncodingHeight,CustomVideoEncodingWidth 的值分别为 0x00000438,0x00000780

浙公网安备 33010602011771号