Showing posts with label winget. Show all posts
Showing posts with label winget. Show all posts

Saturday, July 5, 2025

Windows Sandbox Testing Winget

 

Testing Software Installation with Windows Sandbox

What This Guide Is About

This guide shows you how to safely test software installations using Windows Sandbox - a feature that creates a temporary, isolated copy of Windows on your computer. Think of it as a practice area where you can install programs without affecting your main system.

We'll be using a tool called Winget (Windows Package Manager) to automatically install multiple programs simultaneously, which is significantly faster than downloading and installing each program individually.

Update 2025-08-09 ThioJoe has done this also. Here are his scripts.

Important Notes Before Starting

Different versions of Windows behave differently with Sandbox. If something doesn't work as described, it might be due to your Windows version.

Windows 11 24H2 users: You'll need to add --source winget to the commands because the Microsoft Store isn't accessible in Sandbox. This means you can't install apps that are only available through the Store.

Step 1: Enable Windows Sandbox

  1. Press the Windows key
  2. Type "features"
  3. Click "Turn Windows features on or off"
  4. Check the box next to "Windows Sandbox"
  5. Restart your computer when prompted

Helpful tip: You can copy and paste text between Sandbox and your main computer, but you can't drag and drop files.

Step 2: Create the Necessary Folders

Open Command Prompt and create these folders on your main computer:

mkdir C:\Sandbox
mkdir C:\Sandbox\winget_install

The C:\Sandbox folder will be shared with your Sandbox environment, and winget_install will contain the installation files.

Step 3: Download Required Files

You'll need to download three files from the Microsoft Winget GitHub page:

* 1 & 2 are a single zip file. Open the x64 folder and extract the two files.

  1. Microsoft.VCLibs file (a dependency)
  2. Microsoft.UI.Xaml file (a dependency)
  3. Microsoft.DesktopAppInstaller file (the main Winget installer)

Place all three files in your C:\Sandbox\winget_install folder.

Here is a cmd file to automate the process. Manually extract x64 dependencies.

mkdir C:\Sandbox\winget_install

curl -L https://github.com/microsoft/winget-cli/releases/download/v1.11.400/DesktopAppInstaller_Dependencies.zip -o C:\Sandbox\winget_install\DesktopAppInstaller_Dependencies.zip

curl -L https://github.com/microsoft/winget-cli/releases/download/v1.11.400/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -o C:\Sandbox\winget_install\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Step 4: Create Configuration Files

Basic Sandbox Configuration

Create a file called Sandbox.wsb with this content:

<Configuration>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\Sandbox</HostFolder>
      <ReadOnly>false</ReadOnly>
    </MappedFolder>
  </MappedFolders>
</Configuration>

This tells Sandbox to share your C:\Sandbox folder.

Advanced Configuration (Auto-Install)

For automatic installation when Sandbox starts, use this version instead:
(The powershell.exe extends beyond the right margin to preserve copy, paste, run viability)
<Configuration>
    <MappedFolders>
        <MappedFolder>
            <HostFolder>C:\Sandbox</HostFolder>
            <SandboxFolder>C:\Users\WDAGUtilityAccount\Desktop\Sandbox</SandboxFolder>
            <ReadOnly>false</ReadOnly>
        </MappedFolder>
    </MappedFolders>
    <LogonCommand>
        <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\install.ps1"</Command>
    </LogonCommand>
</Configuration>

This automatically runs the installation script when Sandbox starts.

Step 5: Create Installation Scripts

install.cmd (Simple Launcher)

Create install.cmd in your C:\Sandbox\winget_install folder:

powershell.exe -ExecutionPolicy Bypass -File install.ps1

install.ps1 (Main Installation Script)

Create install.ps1 in your C:\Sandbox\winget_install folder:
(You could use $HOME\ which is the same as %USERPROFILE% in CMD)
# Install required dependencies
Add-AppxPackage "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33728.0_x64.appx"
Add-AppxPackage "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64.appx"
Add-AppxPackage "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
# Wait for winget to be ready Start-Sleep -Seconds 10 # Remove Microsoft Store source to avoid errors winget source remove msstore # Install programs
winget install -e --id Notepad++.Notepad++ --accept-source-agreements --accept-package-agreements --force
winget install -e --id 7zip.7zip --accept-source-agreements --accept-package-agreements --force

This guide shows you how to safely test software installations using Windows Sandbox - a feature that creates a temporary, isolated copy of Windows on your computer. Think of it as a practice area where you can install programs without affecting your main system.

We'll be using a tool called Winget (Windows Package Manager) to automatically install multiple programs simultaneously, which is significantly faster than downloading and installing each program individually.

Important Notes Before Starting

Different versions of Windows behave differently with Sandbox. If something doesn't work as described, it might be due to your Windows version.

Windows 11 24H2 users: You'll need to add --source winget to the commands because the Microsoft Store isn't accessible in Sandbox. This means you can't install apps that are only available through the Store.

Step 1: Enable Windows Sandbox

  1. Press the Windows key
  2. Type "features"
  3. Click "Turn Windows features on or off"
  4. Check the box next to "Windows Sandbox"
  5. Restart your computer when prompted

Helpful tip: You can copy and paste text and files between Sandbox and your main computer, but you can't drag and drop.

Step 2: Create the Necessary Folders

Open Command Prompt and create these folders on your main computer:

mkdir C:\Sandbox
mkdir C:\Sandbox\winget_install

The C:\Sandbox folder will be shared with your Sandbox environment, and winget_install will contain the installation files.

Step 3: Download Required Files

You'll need to download three files from the Microsoft Winget GitHub page:

* 1 & 2 are a single zip file. Open the 64 folder and extract the two files.

  1. Microsoft.VCLibs file (a dependency)
  2. Microsoft.UI.Xaml file (a dependency)
  3. Microsoft.DesktopAppInstaller file (the main Winget installer)

Place all three files in your C:\Sandbox\winget_install folder.

Step 4: Create Configuration Files

Basic Sandbox Configuration

Create a file called Sandbox.wsb with this content:

<Configuration>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\Sandbox</HostFolder>
      <ReadOnly>false</ReadOnly>
    </MappedFolder>
  </MappedFolders>
</Configuration>

This tells Sandbox to share your C:\Sandbox folder.

Advanced Configuration (Auto-Install)

For automatic installation when Sandbox starts, use this version instead:

<Configuration>
    <MappedFolders>
        <MappedFolder>
            <HostFolder>C:\Sandbox</HostFolder>
            <SandboxFolder>C:\Users\WDAGUtilityAccount\Desktop\Sandbox</SandboxFolder>
            <ReadOnly>false</ReadOnly>
        </MappedFolder>
    </MappedFolders>
    <LogonCommand>
        <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\install.ps1"</Command>
    </LogonCommand>
</Configuration>

This automatically runs the installation script when Sandbox starts.

Step 5: Create Installation Scripts

install.cmd (Simple Launcher)

Create install.cmd in your C:\Sandbox\winget_install folder:

powershell.exe -ExecutionPolicy Bypass -File install.ps1

install.ps1 (Main Installation Script)

Create install.ps1 in your C:\Sandbox\winget_install folder:

# Install required dependencies
Add-AppxPackage "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33728.0_x64.appx"
Add-AppxPackage "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64.appx"
Add-AppxPackage "C:\Users\WDAGUtilityAccount\Desktop\Sandbox\winget_install\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
# Wait for winget to be ready Start-Sleep -Seconds 10 # Remove Microsoft Store source to avoid errors winget source remove msstore # Install programs

What This Does

When you run the Sandbox with these configurations:

  1. Creates a safe testing environment - Nothing you do in Sandbox affects your main computer
  2. Automatically installs Winget - Sets up the package manager in the isolated environment
  3. Tests software installation - Installs Notepad++ and 7-Zip as examples
  4. Validates your setup - If programs install successfully in Sandbox, they should work on your real computer

Why This Is Useful

  • Safety first - Test potentially problematic software without risk
  • Batch testing - Try installing multiple programs at once
  • Clean environment - Start fresh each time without leftover files
  • Time saving - Automate repetitive installation tasks

Getting Started

  1. Enable Windows Sandbox
  2. Create the folder structure
  3. Download the required files
  4. Create the configuration and script files
  5. Double-click your Sandbox.wsb file to start

Your Sandbox will open and automatically begin installing the test programs. If everything works, you should be able to continue testing and manipulating other software and scripts.


Here are a couple of scripts I use on new PC setups. They should test successfully on your new Sandbox.

my_install.cmd for further reference (Place this in C:\Sandbox)
I use it on all new system setups, Sandbox was only an experiment. 🤣
If it installs on Sandbox, it will install on hardware.
    Remove the : for non-Sandbox installs.

cd %userprofile%\Desktop
mkdir C:\Portable\Excluded
mkdir C:\Drivers\Benchmarks
mkdir C:\Desk
mkdir %userprofile%\Pictures\Wallpaper
mkdir %userprofile%\\Program Archives
:winget install -e --id=Microsoft.VCRedist.2015+.x64
winget install -e --id=Microsoft.VCRedist.2015+.x86
:winget install -e --id=Chocolatey.Chocolatey
winget install -e --id 7zip.7zip
:winget install -e --id=Notepad++.Notepad++
::UnigetUI
winget install -e --id=MartiCliment.UniGetUI
winget install -e --id=winaero.tweaker
::Wintoys
winget install -e  --accept-source-agreements --accept-package-agreements --id=9P8LTPGCBZXD
winget install -e --id=RevoUninstaller.RevoUninstaller
winget install -e --id=CodeJelly.Launchy
winget install -e --silent --id=IObit.IObitUnlocker
::TranslucentTB
winget install -e --accept-source-agreements --accept-package-agreements --id=9PF4KZ2VN4W9
winget install -e --silent --id=2BrightSparks.SyncBackFree

winget install -e --silent --id=AOMEI.Backupper.Standard
winget install -e --id=AutoHotkey.AutoHotkey
winget install -e --id=voidtools.Everything
:winget install -e --id=AdrienAllard.FileConverter
winget install -e --id=Brave.Brave
winget install -e --id=HexChat.HexChat
winget install -e --id=IrfanSkiljan.IrfanView
winget install -e --id=IrfanSkiljan.IrfanView.PlugIns
winget install -e --id=Microsoft.PowerToys
winget install -e --id=qBittorrent.qBittorrent
winget install -e --id=ShareX.ShareX
:winget install -e --id=Oracle.VirtualBox
winget install -e --id=VideoLAN.VLC

curl.exe -L https://eternallybored.org/misc/wget/1.21.4/64/wget.exe -o C:\Windows\System32\wget.exe
curl.exe -L https://www.ugmfree.it/Download/SyMenu/SyMenu.zip -o C:\Portable\symenu.zip
curl.exe -L https://www.carifred.com/uvk/UVKPortable.exe -o C:\Portable\UVK.exe
curl.exe -L https://www.sordum.org/files/download/defender-exclusion-tool/ExcTool.zip -o C:\Portable\Excluded\ExcTool.zip
curl.exe -L https://downloads.wisecleaner.com/soft/WDCFree_11.1.6.832.zip -o C:\Portable\WDCFree.zip
curl.exe -L https://windows-repair-toolbox.com/files/Windows_Repair_Toolbox.zip -o C:\Portable\Windows_Repair_Toolbox.zip

msg * "irm christitus.com/win | iex"
pause

Separate Extract_Delete.cmd
    No big deal. I just wanted to do it. Manual extract is fast and easy.
    Answer "A" to the first request and all will continue without interruption.

"C:\Program Files\7-Zip\7z.exe" e "C:\Portable\Excluded\ExcTool.zip" -o"C:\Portable\Excluded\ExcTool" && del C:\Portable\Excluded\ExcTool.zip"

"C:\Program Files\7-Zip\7z.exe" e "C:\Portable\Windows_Repair_Toolbox.zip" -o"C:\Portable\Windows_Repair_Toolbox" && del "C:\Portable\Windows_Repair_Toolbox.zip"

"C:\Program Files\7-Zip\7z.exe" e "C:\Portable\symenu.zip" -o"C:\Portable\Symenu" && del "C:\Portable\symenu.zip"

"C:\Program Files\7-Zip\7z.exe" e "C:\Portable\WDCFree.zip" -o"C:\Portable\WDCFree" && del "C:\Portable\WDCFree.zip"

Monday, September 30, 2024

Winget Installing Multiple Programs

Using a .bat file

Note the agreements arguement with the windows store app

winget install -e --id=Chocolatey.Chocolatey
winget install -e --id=7zip.7zip
winget install -e --accept-package-agreements --id=9PF4KZ2VN4W9
pause

(the last install is a windows store package)

    Or

winget install --accept-package-agreements Chocolatey.Chocolatey 7zip.7zip 9PF4KZ2VN4W9
pause

Using a .ps1 file

Nice to have all the arguments on one line. All the "" & commas are a pain.

#Install software
$SoftwareToInstall = "MartiCliment.UniGetUI", "7zip.7zip"
foreach ($Software in $SoftwareToInstall) {
    WinGet.exe install $software --silent --force --accept-source-agreements --accept-package-agreements --disable-interactivity --source winget
}

Windows Sandbox makes it difficult to install Winget.

Here is a .ps1 script that works now but things change.

#Install WinGet, used https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget-on-windows-sandbox
Start-Transcript C:\users\wdagutilityaccount\desktop\Installing.txt
$progressPreference = 'silentlyContinue'
Write-Information "Downloading WinGet and its dependencies..."
Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile $env:temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile $env:temp\Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile $env:temp\Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage $env:temp\Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage $env:temp\Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage $env:temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Stop-Transcript
Rename-Item -Path C:\users\wdagutilityaccount\desktop\Installing.txt -NewName C:\users\wdagutilityaccount\desktop\Done.txt 

Hints:
    For bat scripts just copy/paste into notepad and save/name file "anything.bat"
        Double click should run in Windows & Sandbox
    For ps1 scripts just copy/paste into notepad and save/name file "anything.ps1"
        In regular Windows, double clicking the file will run it.
        In Sandbox, right click and "run with Powershell"

Which one do I like for installing multiple probrams?
    I like the bat file's verticle list and ease of editing
    I also like the continuous list. 
    Just remember store apps need additional argument to avoid interaction during install but can be stated once  with continuous list version.
I guess you could go the Full Monty with below or pick and choose as needed.
--silent --force --accept-source-agreements --accept-package-agreements --disable-interactivity --source winget


Ventoy On Secure Boot

I turn of secure boot in every BIOS. However, some do not show that setting. Here is an option that has worked for me. Boot the PC and launc...