Installing Microsoft Store in Windows Sandbox Using PowerShell Script

Installing Microsoft Store in Windows Sandbox Using PowerShell Script

One of the lesser-known features of the Windows operating system is Windows Sandbox. This tool provides a safe testing environment for executable files. Although, by default, it does not support the Microsoft Store, a straightforward workaround exists that allows you to integrate it using a PowerShell script.

Understanding Windows Sandbox

Windows Sandbox

Introduced at the end of 2018 with Windows 10 version 1903, Windows Sandbox creates a secure, temporary virtual PC. This feature lets users install dubious software or access potentially harmful documents without jeopardizing their actual system. Importantly, everything required to operate Sandbox is built into Windows, eliminating the need for separate virtual hard disk installations.

Available only in Windows 11 Pro and Enterprise editions, as well as equivalent versions of Windows 10, Sandbox is designed for safety and efficiency. Applications installed within the Sandbox environment have no impact on your primary system, and all files, changes, and installations are deleted upon closing the Sandbox. Leveraging hardware-assisted virtualization and Microsoft’s hypervisor, this distinctive kernel environment offers a fresh install of Windows each time you launch it.

These security features, combined with rapid performance—thanks to an integrated kernel scheduler, intelligent memory management, and virtual GPU—make Windows Sandbox a superior choice for application testing compared to traditional virtual machines.

However, the absence of Microsoft Store integration was a letdown because it houses a vast collection of applications.

Desiring Microsoft Store within Windows Sandbox

At Windows Latest, our need to test various software frequently leads to installations that can slow down or disrupt our systems, necessitating multiple resets. Since discovering Sandbox, I have employed it to run executable files, evaluate installers, and access files from unverified sources.

Notably, transferring files from your desktop to Sandbox is as simple as drag-and-drop—an operation that’s not as seamless in conventional virtual machines. Many essential tools and smaller utilities that I wished to explore are exclusively available in the Microsoft Store. While side-loading installation files is an option, it does undermine the swift setup of a secure testing environment.

Having Microsoft Store integrated into Sandbox would allow me to evaluate how various Store apps perform in a pristine Windows installation.

Requirements for Integrating Microsoft Store in Sandbox

If Sandbox is already enabled on your PC, the next step is executing a PowerShell script. However, if you haven’t activated Sandbox, bear in mind that it cannot be used on Windows Home editions; you will need either Pro or Enterprise versions. Additionally, hardware virtualization must be activated within your BIOS/UEFI settings.

  • To verify if virtualization is enabled, press Ctrl + Shift + Esc to access Task Manager.
  • Navigate to the Performance tab and select CPU.
  • At the bottom right, check if Virtualization: indicates Enabled or Disabled.
Task Manager

In most cases, it should be Enabled by default; however, if it displays Disabled, you will need to access the BIOS settings.

  • Restart your computer, pressing the Esc key repeatedly during boot-up.
  • Within the BIOS menu, navigate to Advanced, CPU Configuration, or the Security tab.
  • Locate Intel VT-x or AMD-V and set it to Enabled.
  • Follow the on-screen instructions to save changes and exit the BIOS.

With virtualization enabled, your system is primed for both Sandbox and the subsequent Microsoft Store integration. For those utilizing virtual machines, such as VMware, enable nested virtualization.

The PowerShell script designed to install the Store is independent of external dependencies, but it does require an active internet connection within the Sandbox session to retrieve the installation files from Microsoft’s servers. Caution is advised, as executing the script outside of Sandbox will attempt to install the Microsoft Store on your main system. Ensure that you are operating within the Windows Sandbox environment before running the script.

Activating Sandbox in Windows 11

  1. Press Windows key + S to launch Search, type “Windows features” and select Turn Windows features on or off.Turn Windows features on or off
  2. A legacy window will appear. Scroll down and check the box for Windows Sandbox.Enable Windows Sandbox
  3. Click OK. Windows will proceed with installing the feature.
  4. Restart your computer.
  5. After rebooting, press the Windows key and search for Windows Sandbox to confirm successful installation.Open Windows Sandbox

Installing Windows Sandbox in VMware: Addressing Issues

For those running Windows 11 Pro within VMware, you may notice that the Sandbox option appears grayed out in the legacy window. Follow these steps to enable it:

  1. Ensure that virtualization is already activated on the host running Windows 11 Pro.
  2. Shut down your Windows 11 virtual machine.
  3. In VMware Workstation, right-click the VM and select Settings.
  4. Under the Processors tab, check the option Virtualize Intel VT-x/EPT or AMD-V/RVI to enable nested virtualization.
  5. Once configured, restart the VM and open “Turn Windows features on or off” to enable the Windows Sandbox.
  6. Restart your virtual machine once again.

Keep in mind that if your virtual machine is experiencing performance issues, running Sandbox, despite its lightweight nature, may require additional resources. Ensure your system has enough RAM and CPU resources allocated for smooth operation.

Once your Sandbox is running, you can install the Microsoft Store using the relevant PowerShell script available on GitHub.

Understanding the PowerShell Script Functionality

The PowerShell script responsible for installing the Microsoft Store within Sandbox is straightforward, despite appearing complex. Here’s an overview of its systematic actions:

  1. The script verifies that it is operating within Windows Sandbox by checking for the username (WDAGUtilityAccount).A warning is issued if this condition is not met.
  2. It sends a “GetCookie” request to authenticate via Microsoft’s official Windows Update web services, allowing the download of authorized app packages.
  3. Utilizing the returned cookie, another request (SyncUpdates) is made for packages associated with the Microsoft Store’s category ID, yielding a list of files needed for installation.
  4. It retrieves direct download URLs for each file, including the Store app and its dependencies.
  5. The downloaded files are stored in the Sandbox Downloads folder under a designated subfolder.
  6. Dependencies are installed first through PowerShell’s Add-AppxPackage command.
  7. The main package, Microsoft. WindowsStore, is installed subsequently. Note that the Store will not function without its supporting frameworks already in place.
  8. Finally, the script sets the Sandbox region to the US in the registry since the Store operates inefficiently in Sandbox’s default “World” region.

Executing the Microsoft Store Script in Windows Sandbox

You can access the script to install the Microsoft Store from GitHub without needing to clone the repository or execute complex commands. Here’s how you can do it:

  1. Open the GitHub link in your host’s browser.
  2. Copy the entire PowerShell code directly from the webpage. Use the button at the top right of the code block that reads “Copy raw file”, or manually select and copy the text.
  3. Launch Windows Sandbox on your PC.
  4. Within Sandbox, open Notepad.
  5. Paste the copied text into Notepad.
  6. Save the file with a.ps1 extension, for instance, Install-Store.ps1. When saving, select Save as type: All Files, not just.txt.

I saved my script on the Desktop within Sandbox for easy access.

Running the Microsoft Store Installation Script

After saving the.ps1 file, follow these steps to initiate the Store installation (ensure you’re executing these actions inside Sandbox, not on your primary system):

  1. Right-click the Start button within Sandbox and open Windows Terminal (Admin) or PowerShell (Admin). If the script is on the Desktop, type: cd $env:USERPROFILE\Desktop.
  2. Due to potential script execution restrictions, you may need to temporarily allow script execution using: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process.
  3. This adjustment is safe as all settings revert after this Sandbox session ends.
  4. Run the script by entering the following command, adapted to the file name you chose: .\Install-Store.ps1.
  5. The script will begin retrieving files directly from Microsoft’s servers, downloading necessary packages, including Microsoft. UI. Xaml, .NET Framework dependencies, and ultimately, Microsoft. WindowsStore.
  6. The installation of the Microsoft Store app will automatically proceed.

After installation, access the Start menu in Sandbox and search for the Microsoft Store. Confirm it loads correctly and allows the installation of apps akin to your regular host environment.

Keep in mind that once you close the Sandbox, the Store will be removed, necessitating the re-execution of the script each time you wish to use it within the Sandbox.

Despite Windows Sandbox offering an excellent testing environment and the Microsoft Store gaining popularity, it’s noteworthy that Microsoft has yet to promote Sandbox or grant native support for the Store within this feature. Our assessment suggests that this utility is primarily aimed at enterprise users needing to frequently assess new software. A significant limitation remains; Sandbox is simply not supported in Windows Home editions, even though it often comes pre-installed on many OEM Windows laptops.

Source&Images

Leave a Reply

Your email address will not be published. Required fields are marked *