Launch Windows Sandbox with Winget Enabled

Hello, fellow Windows enthusiasts! In this blog post, I’m going to show you how to use WinGet, the awesome Windows Package Manager CLI tool that lets you discover, install, upgrade, remove and configure applications on Windows 10 and Windows 11 computers. WinGet is a powerful and convenient way to manage your software without having to deal with graphical interfaces or web browsers. You can just type a few commands in your terminal and get things done quickly and efficiently.

But what if you want to use WinGet in a sandbox environment? You know, the Windows Sandbox feature that allows you to run applications in isolation from your main system. Maybe you want to test some new software without affecting your system stability or security. Or maybe you just want to experiment with different versions of applications without messing up your configuration.

Well, unfortunately, WinGet is not available in the sandbox by default. Neither is the Microsoft Store app that distributes WinGet as part of the App Installer package. So how can we get WinGet in the sandbox?

The answer is simple: we can create our own .wsb file. A .wsb file is a configuration file that specifies how Windows Sandbox should run. It can include settings such as networking options, shared folders, mapped drives, startup commands and more. By creating a custom .wsb file, we can download and install WinGet inside the sandbox automatically:

<Configuration>
	<MappedFolders>
		<MappedFolder>
			<HostFolder>c:\software\sandbox</HostFolder>
			<SandboxFolder>c:\software</SandboxFolder>
		</MappedFolder>
		<MappedFolder>
			<HostFolder>C:\Users\alone\Downloads</HostFolder>
			<SandboxFolder>C:\Users\WDAGUtilityAccount\Downloads</SandboxFolder>
			<ReadOnly>true</ReadOnly>
		</MappedFolder>
	</MappedFolders>
	<LogonCommand>
		<Command>powershell -executionpolicy unrestricted -command "start powershell {-noexit -file C:\software\boot.ps1}"</Command>
	</LogonCommand>
</Configuration>

This file will execute boot.ps1 on sandbox login, which is placed into c:\software\sandbox on the host machine and here is the content:

cd ~

Write-Host "installing winget..."
$ProgressPreference='Silent'
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.3.2691/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

sandbox


To contact me, send an email anytime or leave a comment below.