Running automated continuous integration (CI) tests, compilation workloads, or long-running database migrations inside Windows Sandbox often encounters unexpected performance degradation when the guest container enters power-throttling states or triggers idle timeouts. By default, Windows Sandbox inherits balanced power schemes from the host Windows 11 operating system, enabling Modern Standby, CPU frequency scaling, and background process throttling for containerized processes. Using custom Windows Sandbox configuration (.wsb) XML profiles paired with PowerShell power management cmdlets, developers can enforce high-performance execution states and prevent sleep interruptions.
Understanding Windows Sandbox Power Management
Power policies inside Windows Sandbox interact directly with the underlying hypervisor:
powercfg.exe: The primary Windows command-line utility used to query power schemes, configure AC/DC sleep timeouts, and activate high-performance power plans.- CPU Power Throttling: Windows 11 automatically applies EcoQoS (Efficiency Mode) to background applications deemed non-essential, capping thread execution to efficiency cores on hybrid CPU architectures (e.g., Intel 12th-14th Gen).
<LogonCommand>: Directs Windows Sandbox to execute power configuration scripts immediately upon container session initialization.
Authoring the Windows Sandbox WSB Profile
Save the following configuration as High_Performance_Sandbox.wsb on your Windows 11 host machine:
<Configuration>
<VGpu>Enable</VGpu>
<Networking>Default</Networking>
<MemoryInMB>8192</MemoryInMB>
<MappedFolders>
<MappedFolder>
<HostFolder>C:SandboxPowerAssets</HostFolder>
<SandboxFolder>C:PowerConfig</SandboxFolder>
<ReadOnly>true</ReadOnly>
</MappedFolder>
</MappedFolders>
<LogonCommand>
<Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:PowerConfigSet-HighPerformancePower.ps1</Command>
</LogonCommand>
</Configuration>
Authoring the PowerShell Power Management Script
In directory C:SandboxPowerAssets on your host, create Set-HighPerformancePower.ps1:
Write-Host "Configuring Windows Sandbox High-Performance Power Scheme..." -ForegroundColor Cyan
# 1. Activate Ultimate Performance or High Performance scheme
# GUID for High Performance: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
# GUID for Ultimate Performance: e9a42b02-d5df-448d-aa00-03f14749eb61
$HighPerfGuid = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
& powercfg.exe /setactive $HighPerfGuid
Write-Host "Activated High Performance power plan ($HighPerfGuid)." -ForegroundColor Green
# 2. Disable idle sleep timeouts (AC and DC)
& powercfg.exe /change standby-timeout-ac 0
& powercfg.exe /change standby-timeout-dc 0
& powercfg.exe /change monitor-timeout-ac 0
& powercfg.exe /change monitor-timeout-dc 0
Write-Host "Standby and monitor sleep timeouts set to NEVER (0 minutes)." -ForegroundColor Green
# 3. Disable CPU Power Throttling via Registry
$PowerThrottlingPath = "HKLM:SYSTEMCurrentControlSetControlPowerPowerThrottling"
if (!(Test-Path $PowerThrottlingPath)) {
New-Item -Path $PowerThrottlingPath -Force | Out-Null
}
Set-ItemProperty -Path $PowerThrottlingPath -Name "PowerThrottlingOff" -Value 1 -Type DWord
Write-Host "CPU Power Throttling (EcoQoS) disabled system-wide." -ForegroundColor Green
# 4. Query and display active power configuration
Write-Host "Active Power Scheme Details:" -ForegroundColor Yellow
& powercfg.exe /getactivescheme | Write-Host
Write-Host "Sandbox is configured for uninterrupted high-performance testing." -ForegroundColor Cyan
Running and Verifying Uninterrupted Workloads
- Double-click
High_Performance_Sandbox.wsbon your Windows 11 host. - Windows Sandbox launches in seconds.
- The PowerShell window opens automatically upon logon, sets the High Performance scheme, disables monitor/standby timers, and deactivates background CPU throttling.
- Execute heavy long-running test suites, compilation jobs, or continuous load generators without risk of container sleep interruptions.
- Closing Windows Sandbox terminates the session, completely purging all temporary power modifications without affecting the host computer’s battery or power profiles.