How to Set Up and Use Windows Sandbox for Safe App Testing

On
Windows Sandbox wallpaper

If you want to test applications and software in general without affecting your current Windows installation, Windows Sandbox is one of the best options. It gives you an isolated copy of the Windows instance that runs separately from your actual Windows installation. This way, you can easily test applications without worrying about data corruption or malicious software. In this step-by-step tutorial, we'll learn to configure and use Windows Sandbox for testing applications safely and securely. Developers, programmers, and system administrators will find this testing tool, extremely useful.

Windows Sandbox wallpaper
📷 Credit: DALL·E 3

You can compare this feature more or less to running Windows inside Windows, but in a box that doesn't interact with the parent Windows instance in any way. That's what makes it safe to use.

Read Also:
Step-by-Step Guide: Setting Up a Password-Protected Virtual Drive on Windows

Instead of using 3rd-party virtualization software, you can use this inbuilt Windows feature that is free and is light on system resources. It works like a charm and gives you the same result. Let's get started!

Hardware and Software Requirements for Running Windows Sandbox

Before we go ahead to set up and configure Windows Sandbox, let's quickly take a look at the prerequisites for the same. Here's a checklist to see if you Windows system meets the requirement or not.

  • A computer running one of the following Windows variants. Windows 10 Pro, Enterprise, or Education (version 1903 or later) or Windows 11 Pro/Enterprise.
  • Your computer's CPU must support hardware virtualization. Either Intel VT-x or AMD-V depending on the processor you are using.
  • Windows Sandbox will only work on your system if it's running a 64-bit processor. Also, the more cores in your CPU, the better it will be.
  • A minimum of 4GB RAM is required, but if you want the best results, 8GB of RAM is highly recommended.
  • You must have administrative privileges on your Windows system.
  • Last but not least, a minimum of 1GB of free space on your storage device is required.

Now that we know the hardware and software requirements, let's move on to the first step of configuring Windows Sandbox.

Step 1: Enable Windows Sandbox

First, we need to check if virtualization is enabled on our Windows system or not. If not, we need to enable it. Here's how to complete this step.

1.1 Check and Enable Virtualization

To check if virtualization is enabled or not, follow these steps:

  1. Press the Ctrl + Shift + Esc key combination to open the Windows Task Manager application.
    CPU attributes in Task Manager
    📷 Windows Task Manager gives you quick access to CPU attributes
    Go to the PerformanceCPU section. Here, you can see if virtualization is currently enabled or disabled.
  2. If it's disabled, go to your BIOS/UEFI settings. On most computers, F2, F10, F12, DEL, or ESC are the most common keys to enter into the BIOS settings interface. Check with your computer's manual or manufacturer's website to know which key you have to use. Once inside the BIOS interface, find the Virtualization Technology (VT-x for Intel or AMD-V for AMD) setting and enable it. Save, exit, and restart the computer.

1.2 Enable Windows Sandbox via Windows Features

Now that virtualization is enabled in BIOS, it's time to enable the Windows Sandbox feature that is disabled by default. You can do it in two different ways.

In the first method, open Windows PowerShell with administrative privileges and run the following command.

Enable-WindowsOptionalFeature -FeatureName "Containers-DisposableClientVM" -Online -NoRestart

Restart the computer after executing the command given above.

The second method is as follows:

  1. Press the Win + S key and type Turn Windows features on or off in the search box. Click the option to open the application.
    Windows Features Enable or Disable
    📷 Enable the Windows Sandbox feature
  2. Check the Windows Sandbox feature and click the OK button.
  3. It'll take some time for Windows to install the necessary files. Reboot Windows for changes to take effect.

At this point, the Windows Sandbox feature is enabled and ready to use. Let's move on to the next step.

Step 2: Launch Windows Sandbox

There are two ways to launch Windows Sandbox. Either through the start menu or through the Windows search box. In the latter case, use the Win + S key combination to open the search box and type 'Windows Sandbox' to find the app in the search menu. Simply click it to launch it.

Windows Sandbox feature
📷 Launch Windows Sandbox through Start Menu

The second method is much easier. Click the start menu, scroll down, and find the Windows Sandbox menu entry. Click it to launch the application.

Windows Sandbox instance
📷 A lightweight, isolated, and clean copy of a Windows instance

If you are launching Windows Sandbox for the first time, it may take a minute or so to start. Subsequent starts will be much quicker. As you can see in the image above, an isolated Windows instance is running within the application.

Step 3: Using Windows Sandbox for Secure Testing

Testing applications within Windows Sandbox is dead simple. You can transfer your application files or data into this app in two different ways.

Either use the Ctrl + C and Ctrl + V keys to copy the files from the desktop to the application, or simply drag and drop the files through your mouse.

Running app inside Windows Sandbox
📷 Running Rufus portable app inside Windows Sandbox

In the example shown above, I'm running the Rufus portable application within the Windows Sandbox instance. I transferred its portable executable through the regular copy/paste method.

Because Windows Sandbox runs in an isolated environment, you can test and execute almost any software without worrying about infections or data corruption.

Once your testing is done, you can close the Windows Sandbox application. Remember, any data generated by the app you are testing and the app itself will get destroyed as soon as you close the sandbox window.

Step 4: Automating Tasks with Sandbox Configuration Files

If you are curious and want to exercise more control over how your Windows Sandbox instance behaves and runs, you can use the Windows Sandbox configuration file (.wsb) to automate tasks as well as to apply certain attributes to the instance. Let's see some example configuration files to give you a fair idea.

Create a simple text file and make sure it has the .wsb extension. You can edit it in any plain text editor. These configuration files are just XML code or structure.

Example 1: Automatically open Notepad on launch

<Configuration>
  <LogonCommand>
    <Command>cmd.exe /c start notepad.exe</Command>
  </LogonCommand>
</Configuration>

Example 2: Editable custom shared folder with networking support

<Configuration>
       <MappedFolders>
           <MappedFolder>
               <HostFolder>C:\MyFolder</HostFolder>
               <ReadOnly>false</ReadOnly>
           </MappedFolder>
       </MappedFolders>
       <Networking>Enable</Networking>
   </Configuration>

Example 4: Internet access blocked. GPU disabled, and read-only custom shared folder

<Configuration>
     <VGpu>Disable</VGpu> 
     <Networking>Disable</Networking> 
     <MappedFolders>
       <MappedFolder>
         <HostFolder>C:\SandboxConfidential</HostFolder> 
         <ReadOnly>true</ReadOnly> 
       </MappedFolder>
     </MappedFolders>
   </Configuration>

After saving the configuration file, simply double-click on it to launch Windows Sandbox with the custom configuration specified in this file.

Best Practices for Using Windows Sandbox

And here are some of the dos and don'ts while using Windows Sandbox. You can more or less consider them as the best practices while using this excellent testing environment. Here we go!

  • I recommend using it for testing new software, analyzing infected files, and visiting shady websites.
  • If the app requires admin privileges, launch the sandbox with administrative rights.
  • Do not use it for tasks like banking and online shopping.
  • Do not transfer critical data to the sandbox as it'll disappear on app termination.

I'd also recommend closing all other applications while using Windows Sandbox. It'll ensure your sandbox instance smoothly without any hiccups.

Troubleshooting Common Issues

It is possible that you may encounter some issues while configuring or using Windows Sandbox. Here are some of the most common issues you may encounter and the solutions to tackle them.

Issue 1: Windows Sandbox Won’t Launch

  • Cause: Either virtualization is disabled or Hyper-V is enabled.
  • Solution: You must check within BIOS/UEFI settings and enable virtualization, if disabled. Hyper-V also creates to conflict with Windows Sandbox functioning. If it is enabled, you must disable it.
    bcdedit /set hypervisorlaunchtype off
    Fire this command in PowerShell and reboot the Windows system.

Issue 2: Slow Performance

  • Cause: Limited system resources available for the Sandbox instance.
  • Solution: Through the configuration .wsb file, you can allocate more CPU and RAM for the Sandbox instance. Also, make sure to close any other application currently running on your system.

Issue 3: Missing Sandbox Option

  • Cause: Your Windows copy doesn't support this feature.
  • Solution: Simply upgrade to Windows 10 Pro, Education, or Enterprise Edition.

Conclusion

Windows Sandbox is a powerful and easy-to-use tool for secure testing. Whether you’re experimenting with new software, debugging code, or analyzing potentially malicious files, Sandbox provides a safe and isolated environment.

By following this tutorial, you can set up and utilize Windows Sandbox effectively, ensuring your main system remains protected. Start exploring Windows Sandbox today and enjoy a safer computing experience!