Monday, September 23, 2024

Windows Sandbox Testing Winget

Before we get to Winget, a short mention of more fun.
    I've never tried Tron script.
        Browsers treat it like the plague and refuse to download Tron.
        In Sandbox install PaleMoon and download.
            Better yet copy/paste portable PaleMoon into Sandbox :)
        Run Tron . . . it's interesting. Install Net 3.5 first or Stinger won't run.
    (Sandbox can't "turn features on/off - it does have limitations so no Stinger)
            In regular Windows download Tron with torrent
    Brilliant idea - Copy/paste PatchmyPC and install stuff.

Ok - back to Winget
It's great but don't expect it to do everything full Windows does.
While perfecting my "perfect" Winget appslist.json it worked great.
    Need to alter the list and try again? No problem Close Sandbox and restart clean.

Enable Windows Sandbox Feature
    copy/paste between sandbox & host system works
open sandbox

See Faster Winget Install On Bottom Of This Post

Chris Titus WinUtil
    powershell admin
        iwr -useb https://christitus.com/win | iex
        install UnigetUI
            will install winget
                and ask to install UnigetUi - say no today WinUtil has the wrong info now
                    click the little ? by UnigetUi and Uniget's website will open for download
OR
    Install UnigetUI
OR
    winget install MartiCliment.UniGetUI

Now open UniGetUI and it will install chocolatey.
    Close it. When you open it again choco search will work.
  
Copy the json below into a Notepad file and save as "appslist" on the sandbox desktop

Open Command Prompt
*The name of the file doesn't matter
    It must be a valid json format
        The name must match the entry in the command line
            Editing the json (if needed) in Notepad++ makes life easier!

Export command:
winget export -o %userprofile%\desktop\appslist --accept-source-agreements

Import command
winget import -i %userprofile%\desktop\appslist --ignore-versions --accept-package-agreements --accept-source-agreements

It takes awhile to load so be patient.

If app install fails error code 1 check VCRedist.2015+.x64 is installed.

If errors occur validate the json file here https://jsonlint.com/
Also check the file extension matches the command.
    Sandbox defaults to not show file extensions.
Open file explorer > view and check file extension. 
    You need to either delete ".txt" or add .txt to the import command.

A few install popus appeared but the install was not affected.
    RocketDock failed with hash not match. Couldn't install without swithches.
    Failures do not stop the installs.

By the way . . . RocketDock installs just fine in UnigetUI with Chocolatey.
UnigetUI installs Chocolatey when you start it the first time.
I also get LaunchyQT with Chocolatey.

            choco install rocketdock launchyqt irfanviewplugins -y

Observation
    UnigetUi bundles.json sometimes fails on simple installs like 7zip
    Where as Winget appslist.json does not fail

For now, I prefer Winget appslist.json installs.

appslist file

{
"$schema" : "https://aka.ms/winget-packages.schema.2.0.json",
"CreationDate" : "2024-09-29T09:35:27.698-00:00",
"Sources" : 
[
{
"Packages" : 
[
{
"PackageIdentifier" : "MartiCliment.UniGetUI"
},
{
"PackageIdentifier" : "ShareX.ShareX"
},
{
"PackageIdentifier" : "AutoHotkey.AutoHotkey"
},
{
"PackageIdentifier" : "voidtools.Everything"
},
{
"PackageIdentifier" : "HexChat.HexChat"
},
{
"PackageIdentifier" : "IrfanSkiljan.IrfanView"
},
{
"PackageIdentifier" : "Mozilla.Firefox"
},
{
"PackageIdentifier" : "Notepad++.Notepad++"
},
{
"PackageIdentifier" : "Proton.ProtonVPN"
},
{
"PackageIdentifier" : "VideoLAN.VLC"
},
{
"PackageIdentifier" : "winaero.tweaker"
},
{
"PackageIdentifier" : "nepnep.neofetch-win"
},
{
"PackageIdentifier" : "7zip.7zip"
},
{
"PackageIdentifier" : "AdrienAllard.FileConverter"
},
{
"PackageIdentifier" : "Microsoft.PowerShell"
},
{
"PackageIdentifier" : "Oracle.VirtualBox"
},
{
"PackageIdentifier" : "Google.Chrome.EXE"
},
{
"PackageIdentifier" : "2BrightSparks.SyncBackFree"
},
{
"PackageIdentifier" : "Chocolatey.ChocolateyGUI"
},
{
"PackageIdentifier" : "AOMEI.Backupper.Standard"
},
{
"PackageIdentifier" : "flux.flux"
},
{
"PackageIdentifier" : "LocalSend.LocalSend"
},
{
"PackageIdentifier" : "Microsoft.PowerToys"
}
],
"SourceDetails" : 
{
"Argument" : "https://cdn.winget.microsoft.com/cache",
"Identifier" : "Microsoft.Winget.Source_8wekyb3d8bbwe",
"Name" : "winget",
"Type" : "Microsoft.PreIndexed.Package"
}
},
{
"Packages" : 
[
{
"PackageIdentifier" : "9N0DX20HK701"
}
],
"SourceDetails" : 
{
"Argument" : "https://storeedgefd.dsx.mp.microsoft.com/v9.0",
"Identifier" : "StoreEdgeFD",
"Name" : "msstore",
"Type" : "Microsoft.Rest"
}
}
],
"WinGetVersion" : "1.8.1911"
}

Fast Powershell Winget Install Script

I looked all over & tried different way to install Winget on Sandbox without Chris Titus' help.
    I finally found this smart guy HERE 
        Much faster than the Chris Titus way of doing it
            Download, paste into Sandbox, right click, run with powershell

Or 

You can copy, paste this into a test file and save it as "Install_WinGet_and_Software.ps1"
    Or name it "Santa.ps1" for that matter.
        I removed install VSCode and added 7zip to have two installs so we see the pattern.

This is the Powershell script . . .

#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

#Install software
$SoftwareToInstall = "Notepad++.Notepad++", "7zip.7zip"
foreach ($Software in $SoftwareToInstall) {
    WinGet.exe install $software --silent --force --accept-source-agreements --disable-interactivity --source winget
}
Stop-Transcript
Rename-Item -Path C:\users\wdagutilityaccount\desktop\Installing.txt -NewName C:\users\wdagutilityaccount\desktop\Done.txt

If you download the appx package on your own:
    in notepad & save script as "something.ps1" right click and run with powershell
Add-AppxPackage -path "C:\Users\WDAGUtilityAccount\Downloads\Microsoft.VCLibs.x64.14.00.Desktop.appx"

OK, Good Grief - How Many Of These Do We Need? (bat files are easier)
    Here is a ps1 to install programs only. I like how we put the switches on one command.
    The "", syntax is a pain.
    The --accept-package-agreements avoids answering "yes" to agreement

#Install software
$SoftwareToInstall = "MartiCliment.UniGetUI", "7zip.7zip", "2BrightSparks.SyncBackFree", "AOMEI.Backupper", "AutoHotkey.AutoHotkey", "Brave.Brave", "Chocolatey.ChocolateyGUI". "voidtools.Everything", "AdrienAllard.FileConverter", "Google.Chrome", "HexChat.HexChat", "IrfanSkiljan.IrfanView", "JavadMotallebi.NeatDownloadManager", "localsend", "Microsoft.PowerToys", "Notepad++.Notepad++", "qBittorrent.qBittorrent", "ShareX.ShareX", "Microsoft.WindowsTerminal", "Oracle.VirtualBox", "VideoLAN.VLC", "CharlesMilette.TranslucentTB", "9P8LTPGCBZXD", "RevoUninstaller.RevoUninstaller", "winaero.tweaker"
foreach ($Software in $SoftwareToInstall) {
    WinGet.exe install $software --silent --force --accept-source-agreements --accept-package-agreements --disable-interactivity --source winget
}

Downloading With Curl

Open CMD in directory you want the file curl -O -L "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.U...