Windows Sandbox provides an ideal disposable test bed for evaluating unstable drivers, pre-release software builds, and untrusted binaries. However, because Windows Sandbox automatically destroys all virtual disks and RAM state upon closing, diagnosing unexpected application crashes or kernel panics (BSOD) presents a unique challenge: all diagnostic dump files (.dmp) are wiped before developers can extract them. By integrating mapped host directories, automated registry dump configuration, and PowerShell logon scripts, you can capture full user-mode memory dumps directly to your physical host storage in Windows 11.
Understanding Windows Error Reporting (WER) Dump Scope
Windows Error Reporting (WER) can be configured via the Windows Registry to automatically generate Local Dumps whenever any process terminates abnormally. By directing WER’s DumpFolder to a mapped host directory, crash artifacts survive container termination intact.
Authoring the Crash Diagnostic Provisioning Script
Create a dedicated host folder (e.g. C:\SandboxTelemetry) and save a PowerShell script named InitDiagnostics.ps1:
# InitDiagnostics.ps1 - Configure crash dump persistence
Write-Host "Configuring automated Windows Error Reporting dumps..." -ForegroundColor Cyan
$werPath = "HKLM:SOFTWAREMicrosoftWindowsWindows Error ReportingLocalDumps"
if (-not (Test-Path $werPath)) {
New-Item -Path $werPath -Force | Out-Null
}
# Configure dump folder pointing to mapped host directory
Set-ItemProperty -Path $werPath -Name "DumpFolder" -Value "C:CrashOutput" -Type ExpandString
Set-ItemProperty -Path $werPath -Name "DumpCount" -Value 10 -Type DWord
Set-ItemProperty -Path $werPath -Name "DumpType" -Value 2 -Type DWord # 2 = Full Dump, 1 = MiniDump
Write-Host "WER LocalDumps configured. Target: C:CrashOutput" -ForegroundColor Green
Constructing the Diagnostics WSB Configuration File
Create an XML configuration file named DiagnosticSandbox.wsb on your desktop:
<Configuration>
<VGpu>Enable</VGpu>
<Networking>Default</Networking>
<MemoryInMB>8192</MemoryInMB>
<MappedFolders>
<MappedFolder>
<HostFolder>C:SandboxTelemetry</HostFolder>
<SandboxFolder>C:CrashOutput</SandboxFolder>
<ReadOnly>false</ReadOnly>
</MappedFolder>
</MappedFolders>
<LogonCommand>
<Command>powershell.exe -ExecutionPolicy Bypass -File C:CrashOutputInitDiagnostics.ps1</Command>
</LogonCommand>
</Configuration>
Simulating a Crash and Verifying Dump Capture
To verify that crash artifacts are captured successfully to your physical host:
- Double-click
DiagnosticSandbox.wsbto boot the sandbox environment. - Inside the sandbox, simulate a deliberate application crash via PowerShell:
Stop-Process -Id $PID -Force - Alternatively, launch your unstable test application inside the sandbox. When an unhandled exception or crash occurs, Windows Error Reporting immediately writes a complete
.dmpfile toC:\CrashOutput. - Switch to your physical Windows 11 host machine. Open
C:\SandboxTelemetryin File Explorer and confirm that the timestamped.dmpmemory dump file is present and readable. - Open the captured dump file on your host machine using WinDbg or Visual Studio to analyze the crash stack trace, registers, and memory state.