Windows Sandbox provides an ephemeral, isolated Hyper-V desktop environment for malware analysis, software testing, and clean-room development. When deploying multiple sandbox instances across enterprise environments or demonstration setups, distinctive visual branding, dark mode enforcement, and watermark wallpapers prevent operators from confusing sandbox windows with the host OS. This tutorial details how to configure Windows Sandbox custom desktop themes and wallpapers using WSB XML configuration files and automated PowerShell provisioning.
Windows Sandbox Architecture and Visual Customisation
Because Windows Sandbox resets to a pristine baseline state after every shutdown, desktop appearance modifications cannot be permanently saved to disk. Instead, customisation relies on the <LogonCommand> element within a .wsb configuration file. By mounting a host directory containing high-resolution wallpapers and an automated setup script via <MappedFolders>, the sandbox executes visual customisations immediately upon shell launch.
Structuring Host Folders for Assets
Create a dedicated configuration directory on your Windows 11 host (for example, C:\SandboxConfig). Structure the folder with the following assets:
C:\SandboxConfig\
├── Wallpaper.png
├── Set-SandboxTheme.ps1
└── CustomTheme_Sandbox.wsb
Authoring the Theme Provisioning Script
Save the following PowerShell script as C:\SandboxConfig\Set-SandboxTheme.ps1. This script updates the user registry to configure dark mode, sets the desktop wallpaper using Win32 API calls, and refreshes the desktop shell:
# Set-SandboxTheme.ps1 - Automated Sandbox Visual Configuration
param (
[string]$WallpaperPath = "C:\SandboxAssets\Wallpaper.png"
)
# 1. Enable Windows 11 Dark Mode for Apps and System
$ThemeKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
Set-ItemProperty -Path $ThemeKey -Name "AppsUseLightTheme" -Value 0 -Type DWord
Set-ItemProperty -Path $ThemeKey -Name "SystemUsesLightTheme" -Value 0 -Type DWord
# 2. Update Desktop Wallpaper via SystemParametersInfo Win32 API
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Wallpaper {
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
}
"@
if (Test-Path $WallpaperPath) {
# SPI_SETDESKWALLPAPER = 0x0014, SPIF_UPDATEINIFILE = 0x01, SPIF_SENDCHANGE = 0x02
[Wallpaper]::SystemParametersInfo(0x0014, 0, $WallpaperPath, 0x01 -bor 0x02)
Write-Host "Desktop background updated successfully." -ForegroundColor Green
} else {
Write-Warning "Wallpaper file not found at: $WallpaperPath"
}
# 3. Customise Taskbar and Accent Colour
$DwmKey = "HKCU:\Software\Microsoft\Windows\DWM"
Set-ItemProperty -Path $DwmKey -Name "AccentColor" -Value 0xFFB03000 -Type DWord # Vivid Teal
Set-ItemProperty -Path $DwmKey -Name "ColorizationColor" -Value 0xFFB03000 -Type DWord
Write-Host "Sandbox visual theme applied." -ForegroundColor Cyan
Creating the WSB Configuration File
Create CustomTheme_Sandbox.wsb with mapped read-only folder access and automated script execution:
<Configuration>
<VGpu>Enable</VGpu>
<Networking>Default</Networking>
<MappedFolders>
<MappedFolder>
<HostFolder>C:\SandboxConfig</HostFolder>
<SandboxFolder>C:\SandboxAssets</SandboxFolder>
<ReadOnly>true</ReadOnly>
</MappedFolder>
</MappedFolders>
<LogonCommand>
<Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\SandboxAssets\Set-SandboxTheme.ps1 -WallpaperPath C:\SandboxAssets\Wallpaper.png</Command>
</LogonCommand>
</Configuration>
Launching and Verifying the Isolated Environment
- Ensure Windows Sandbox is enabled in Turn Windows features on or off.
- Right-click
CustomTheme_Sandbox.wsband select Open with > Windows Sandbox. - Upon startup, Windows Sandbox mounts
C:\SandboxConfigintoC:\SandboxAssets. - The logon command automatically triggers PowerShell, toggling system interfaces to Dark Mode, registering accent colours, and rendering your custom corporate or diagnostic background image.
- All customisations persist for the duration of your testing session and leave zero residual files on the host upon window closure.