Modal logo

Windows Sandboxes

Modal Sandboxes can run Windows Server 2025. Pass a Windows Image to Sandbox.create() and standard Sandbox APIs (exec(), modal shell, Sandbox.filesystem, Volumes, Cloud Bucket Mounts, Secrets, snapshots, Tunnels, Connect Tokens, and outbound allowlists) work out of the box.

Getting started 

Start from Modal’s Windows Server 2025 Named Image (modal/base/windows-server:latest, or a date-pinned tag like modal/base/windows-server:2026-12-03 for reproducible builds):

import modal

app = modal.App.lookup("windows-sandbox", create_if_missing=True)
image = modal.Image.from_name("modal/base/windows-server:latest")

sb = modal.Sandbox.create(app=app, image=image, cpu=4, memory=8192)
try:
    p = sb.exec("cmd", "/c", "ver && whoami")
    print(p.stdout.read())
finally:
    sb.terminate()

Customizing the Image 

Customize the base Image by booting a Sandbox, installing packages via exec(), and saving a Filesystem Snapshot as a Named Image.

Filesystem Snapshots expire after 30 days by default. Disable expiry when building a long-lived Image (see Snapshot Retention):

import modal

app = modal.App.lookup("windows-image-build", create_if_missing=True)
base = modal.Image.from_name("modal/base/windows-server:2026-12-03")

sb = modal.Sandbox.create(app=app, image=base, cpu=4, memory=8192)
try:
    p = sb.exec(
        "powershell",
        "-NoProfile",
        "-Command",
        "$ErrorActionPreference = 'Stop'; "
        "Invoke-WebRequest -UseBasicParsing https://example.com/app.msi -OutFile C:\\app.msi; "
        "$p = Start-Process msiexec.exe -Wait -PassThru -ArgumentList '/i C:\\app.msi /qn /norestart'; "
        "if ($p.ExitCode -ne 0) { exit $p.ExitCode }",
    )
    if (code := p.wait()) != 0:
        raise RuntimeError(f"installer failed with exit code {code}")
    sb.snapshot_filesystem(ttl=None).publish("my-windows-env:v1")
finally:
    sb.terminate()

# Launch later from your published Image
sb2 = modal.Sandbox.create(
    app=app,
    image=modal.Image.from_name("my-windows-env:v1"),
    cpu=4,
    memory=8192,
)
try:
    ...
finally:
    sb2.terminate()

Desktop and computer use 

Windows Sandboxes include a 1920x1080 desktop display, so GUI apps, screenshots (Pillow, mss, pyautogui), and mouse/keyboard input (pyautogui, pywinauto, Windows UI Automation) work directly from exec().

Fast rollouts with Memory Snapshots 

For fast startup in evals or computer-use loops, take a Memory Snapshot of a booted Sandbox and restore from it.

Wait for all exec() calls to finish before taking a Memory Snapshot, and start any GUI app or background service you want open in the snapshot from the Sandbox entrypoint or a Windows scheduled task (processes started by exec() stop when that exec() exits; see Memory Snapshot limitations).

Viewing the desktop live 

Install a VNC server (such as TightVNC + noVNC) and expose it over encrypted_ports with Connect Tokens for authenticated browser access, or over unencrypted_ports for raw VNC (5900). See Watch a computer-use agent work in real-time over VNC for the general VNC-over-tunnel pattern on Modal.

Resources and pricing 

  • CPU: 0.125 vCPUs minimum and default; CPU bursting works the same as on Linux Sandboxes.
  • Memory: 2048 MiB minimum and default. Memory bursting is not supported yet, so size memory for peak usage.
  • Disk: 512 GiB.

Windows Sandbox pricing:

ResourcePer secondPer hour
CPU$0.00005913 / vCPU / s$0.2129 / vCPU / hr
Memory$0.00000667 / GiB / s$0.0240 / GiB / hr

See Sandbox pricing and resources for general billing details.

Limitations 

  • Directory Snapshots: snapshot_directory() and mount_image() are not supported.
  • Sidecars: Sandbox Sidecars are not supported.
  • Secret injection and HTTPS inspection: Secret injection and HTTPS-decrypting Outbound Policies are not supported. IP/CIDR and domain allowlists work.
  • block_network=True: Use outbound_policy=modal.OutboundPolicy(routes=[modal.OutboundRoute.any().block()]) to block outbound traffic instead.
  • Drive-letter paths in SDKs: Pass /... paths (rooted on C:\, e.g. /Users/Administrator/app) to workdir, volumes, cloud_bucket_mounts, and Sandbox.filesystem instead of C:\....
  • GPUs and ARM64: Windows Sandboxes run on x86_64 CPUs only.
  • Sandboxes only: Modal Functions, Classes, and Endpoints are not supported.