How to Configure Windows Sandbox Custom WSB Configuration Files, Folder Mapping, and Logon Commands

In cybersecurity analysis, software testing, and enterprise systems administration, inspecting suspicious email attachments, untrusted executables, or unknown browser scripts directly on a production workstation introduces extreme operational risk. Spinning up a traditional full-sized virtual machine in Hyper-V or VMware consumes tens of gigabytes of disk space and requires lengthy OS installation routines. Microsoft engineered Windows Sandbox to provide an instant, lightweight, disposable virtual computing environment built directly into Windows 10 and 11 Pro and Enterprise.

Operating through Hyper-V hardware virtualization and a “Dynamic Base Image” (which shares the host’s clean system binaries via copy-on-write memory), Windows Sandbox boots in seconds and guarantees absolute ephemerality: closing the window permanently obliterates all files, registry changes, and memory traces. However, running the default sandbox requires manual folder copying and software installation every session. By authoring custom .wsb XML configuration manifests, administrators can automate host folder mapping, air-gap virtual networking for malware detonation, and execute automated logon scripts on boot.

Architectural Overview: The Windows Sandbox Hyper-V Micro-VM

Windows Sandbox operates as a tightly integrated containerized virtual machine:

Architectural Layer Technical Implementation Security / Operational Function
Dynamic Base Image Immutable Host Package Linking Shares uncorrupted system binaries directly from the host Windows install; consumes zero static disk space for a base OS image.
Snapshot Lifecycle Volatile Copy-on-Write Disk Sandbox All writes occur in an ephemeral RAM/disk scratch space; closing the sandbox instantly wipes the entire guest state.
vGPU Virtualisation Hardware-Accelerated DirectX/Direct3D Paravirtualized GPU rendering shared with the host graphics driver; can be disabled for malware analysis.
Integrated Scheduler Host-Aware Virtual Processor Coordination Schedules guest threads with the same priority as host processes, eliminating virtualisation latency.

Enabling Windows Sandbox in Windows 11

Windows Sandbox requires hardware virtualization enabled in BIOS/UEFI and must be activated as an optional Windows feature.

Step 1: Verify Hardware Virtualization

Press Ctrl + Shift + Esc to open Task Manager, click the Performance tab, select CPU, and confirm that Virtualization displays Enabled.

Step 2: Install Windows Sandbox via PowerShell

Launch an elevated PowerShell console as Administrator:

# Enable Windows Sandbox feature
Enable-WindowsOptionalFeature -Online -FeatureName "Containers-DisposableClientVM" -All -NoRestart

# Restart your workstation if prompted
Restart-Computer

Authoring Custom .wsb XML Configuration Manifests

Windows Sandbox configurations are defined within standard XML files using the .wsb file extension. Double-clicking any .wsb file launches a bespoke sandbox customized to that specific manifest.

The Anatomy of a Production .wsb File

A complete .wsb manifest incorporates directives for hardware acceleration, virtual networking, memory allocation, storage folder mounts, and automated bootstrap commands:

<Configuration>
  <!-- Hardware GPU acceleration: Default, Enable, or Disable -->
  <VGpu>Default</VGpu>

  <!-- Virtual network adapter: Default (Connected) or Disable (Air-gapped) -->
  <Networking>Default</Networking>

  <!-- Dedicated RAM allocation cap in Megabytes -->
  <MemoryInMB>8192</MemoryInMB>

  <!-- Host Directory Passthrough Mounts -->
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\SecurityTools</HostFolder>
      <SandboxFolder>C:\Users\WDAGUtilityAccount\Desktop\Tools</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>

  <!-- Automated Script Execution Upon Guest Boot -->
  <LogonCommand>
    <Command>C:\Users\WDAGUtilityAccount\Desktop\Tools\bootstrap.cmd</Command>
  </LogonCommand>
</Configuration>

Scenario 1: Building an Air-Gapped Malware Detonation Sandbox

When analyzing untrusted binaries, you must prevent the malware from calling home to command-and-control (C2) servers or spreading across your local corporate subnet.

Step 1: Create the Isolated Manifest File

Save the following XML as Malware_Detonation.wsb on your host desktop:

<Configuration>
  <!-- Disable virtual networking completely to prevent C2 communication -->
  <Networking>Disable</Networking>

  <!-- Disable GPU acceleration to mitigate GPU-based exploit escapes -->
  <VGpu>Disable</VGpu>

  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\SuspiciousSamples</HostFolder>
      <SandboxFolder>C:\Users\WDAGUtilityAccount\Desktop\Quarantine</SandboxFolder>
      <!-- Enforce ReadOnly to guarantee malware cannot alter host files -->
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
</Configuration>

Step 2: Detonate and Inspect

Double-click Malware_Detonation.wsb. Windows Sandbox boots into an entirely air-gapped container with no internet connection. The suspicious payload is accessible in the Quarantine desktop folder as read-only. Once analysis is concluded, close the sandbox window: all executed processes and injected registry hooks vanish permanently.

Scenario 2: Automated Development Environment with Bootstrap Scripts

Automate testing of new application installers by mounting tools and executing unattended installations on boot.

Step 1: Create the Bootstrap Batch File

On your host system at C:\DevTools\bootstrap.cmd, save the following setup commands:

@echo off
echo Initializing Disposable Development Environment...
powershell -Command "Set-ExecutionPolicy RemoteSigned -Force"
powershell -Command "winget install --id Git.Git -e --accept-source-agreements --accept-package-agreements"
powershell -Command "winget install --id Microsoft.VisualStudioCode -e --accept-source-agreements --accept-package-agreements"
echo Environment Ready.

Step 2: Author the Development .wsb Configuration

Save this manifest as Dev_Environment.wsb:

<Configuration>
  <Networking>Default</Networking>
  <MemoryInMB>8192</MemoryInMB>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\DevTools</HostFolder>
      <SandboxFolder>C:\Users\WDAGUtilityAccount\Desktop\DevTools</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>C:\Users\WDAGUtilityAccount\Desktop\DevTools\bootstrap.cmd</Command>
  </LogonCommand>
</Configuration>

Double-clicking Dev_Environment.wsb launches the sandbox, connects to the internet, maps your host tool directory, and automatically installs Git and VS Code via Windows Package Manager (winget) without any manual intervention.

Troubleshooting Windows Sandbox and WSB Launch Errors

Consult this diagnostic reference table to debug startup crashes and configuration rejections:

Error Message / Symptom Underlying Root Cause Remediation Procedure
Error 0x80070002: The system cannot find the file specified. The <HostFolder> path specified in the .wsb XML file does not exist on the host machine. Verify the absolute path on the host system. Ensure host folders are created before launching the .wsb file.
Error 0x80070569: The logon attempt failed. The user account running Windows Sandbox lacks the “Log on as a batch job” user right assignment in local security policy. Open secpol.msc > Local Policies > User Rights Assignment and add your user account to Log on as a batch job.
LogonCommand fails to execute scripts automatically. Command string contains complex unescaped arguments or attempts to run PowerShell directly without command switches. Wrap multi-command logic in an external .cmd or .bat script inside a mapped folder and call the batch file from <Command>.
Error 0x80370102: The virtual machine could not be started because a required feature is not installed. Hardware-assisted virtualization is disabled in motherboard firmware, or Hyper-V hypervisor is disabled. Reboot into UEFI/BIOS and enable Intel VT-x / AMD-V and SVM Mode. Ensure Hyper-V platform features are active in Windows.

Mastering custom .wsb configuration files, strict read-only folder mappings, and automated logon bootstrapping unlocks the full potential of Windows Sandbox, providing an indispensable, disposable bastion for rapid software testing and secure malware investigation.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.