Virtualization Share Host Folder with Windows Sandbox in Windows 11


  • Staff
Windows_Sandbox_banner.png

This tutorial will show you how to share host folders with read or write permissions in Windows Sandbox for your account in Windows 11.

Windows Sandbox provides a lightweight desktop environment to safely run applications in isolation. Software installed inside the Windows Sandbox environment remains "sandboxed" and runs separately from the host machine.

A sandbox is temporary. When it's closed, all the software and files and the state are deleted. You get a brand-new instance of the sandbox every time you open the app.

You can use a Windows Sandbox configuration (.wsb) file to share folders from the host with read or write permissions.

Starting with Windows 11 build 27686.1000 (Canary), this build includes the new Windows Sandbox Client Preview that is now updated via the Microsoft Store. As part of this preview, Microsoft is introducing runtime clipboard redirection, audio/video input control, and the ability to share folders with the host at runtime. You can access these via the new “…” icon at the upper right on the app. Additionally, this preview includes a super early version of command line support (commands may change over time). You can use ‘wsb.exe –help’ command for more information.

Reference:

Windows Sandbox is only available in the Windows 11 Pro, Enterprise, and Education editions.


Exposing host directories might allow malicious software to affect the system or steal data.




Contents

  • Option One: Share Host Folder(s) with Windows Sandbox at Runtime
  • Option Two: Share Host Folder(s) with Windows Sandbox using WSB file




Option One

Share Host Folder(s) with Windows Sandbox at Runtime


This option is only available starting with Windows 11 build 27686.1000 (Canary).


1 Open the Windows Sandbox app.

2 Click/tap on the 3 dots icon at the upper right, and click/tap on Share folder. (see screenshot below)

Share_host_folder_with_Windows_Sandbox-1.jpg

3 Navigate to and select the host folder you want to share, and click/tap on Select Folder. (see screenshot below)

Share_host_folder_with_Windows_Sandbox-2.png

4 Repeat steps 2 and 3 if you want to share any other host folder(s) with Windows Sandbox.

5 The shared host folder(s) will now appear on the desktop of Windows Sandbox until you close Windows Sandbox. (see screenshot below)

Share_host_folder_with_Windows_Sandbox-3.jpg




Option Two

Share Host Folder(s) with Windows Sandbox using WSB file


The .wsb file created using this option acts as a shortcut to open Windows Sandbox with the specified shared host folder(s) always available.


1 On the host (not Windows Sandbox), create a new text file where (ex: Desktop) you want to use it as a shortcut from, and name it MappedFolders.wsb.

You can name the text file anything you want, but you must change the .txt file extension to .wsb.


2 Right click on the MappedFolders.wsb file, and click/tap on Edit in Notepad.

3 Copy and paste the code you want to use below into the MappedFolders.wsb file opened in Notepad.

For read-only shared host folder(s)

<Configuration> <MappedFolders> <MappedFolder> <HostFolder>Full path to folder</HostFolder> <ReadOnly>true</ReadOnly> </MappedFolder> </MappedFolders> </Configuration>

For not read-only shared host folder(s)

<Configuration> <MappedFolders> <MappedFolder> <HostFolder>Full path to folder</HostFolder> <ReadOnly>false</ReadOnly> </MappedFolder> </MappedFolders> </Configuration>

4 Edit the line below to change Full path to folder with the actual full path of the host folder you want to share in Windows Sandbox.

<HostFolder>Full path to folder</HostFolder>

For example: <HostFolder>C:\Users\Brink\Downloads</HostFolder>

5 If you want to share multiple host folders, you can add another section below to the code for each folder you want and each with read-only (true) or write (false) permissions

<MappedFolder> <HostFolder>Full path to folder</HostFolder> <ReadOnly>false</ReadOnly> </MappedFolder>

OR​

<MappedFolder> <HostFolder>Full path to folder</HostFolder> <ReadOnly>true</ReadOnly> </MappedFolder>

EXAMPLE of code for three shared host folders:

<Configuration> <MappedFolders> <MappedFolder> <HostFolder>Full path to folder1</HostFolder> <ReadOnly>false</ReadOnly> </MappedFolder> <MappedFolder> <HostFolder>Full path to folder2</HostFolder> <ReadOnly>true</ReadOnly> </MappedFolder> <MappedFolder> <HostFolder>Full path to folder3</HostFolder> <ReadOnly>false</ReadOnly> </MappedFolder> </MappedFolders> </Configuration>


6 When finished editing the code in the MappedFolders.wsb file opened in Notepad, click/tap on File on the menu bar, and click/tap on Save. (see screenshots below).

finsihed.png
Save.png

7 You can now run this MappedFolders.wsb file anytime you want to open Windows Sandbox with the shared host folder(s) available on the desktop of Windows Sandbox.


That's it,
Shawn Brink


 
Last edited:
Back
Top Bottom