Last active
February 19, 2025 14:38
-
-
Save rxwx/74df13b83202c9377843c666ea83a08c to your computer and use it in GitHub Desktop.
Install winget in Windows Sandbox (fix)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix wmi | |
winmgmt /resetrepository | |
Restart-Service Winmgmt | |
Get-CimInstance -Namespace root/cimv2 -ClassName Win32_PingStatus -Filter "Address='www.microsoft.com'" | |
# alternative method: set high bandwidth limit for Delivery Optimization | |
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" /v "DownloadMode" /t REG_DWORD /d 0 /f | |
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" /v "DownloadModeProvider" /t REG_DWORD /d 8 /f | |
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" /v "DownloadRateBackgroundBps" /t REG_DWORD /d 4294967295 /f | |
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" /v "DownloadRateBackgroundBpsProvider" /t REG_DWORD /d 8 /f | |
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" /v "DownloadRateForegroundBps" /t REG_DWORD /d 4294967295 /f | |
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" /v "DownloadRateForegroundBpsProvider" /t REG_DWORD /d 8 /f | |
# install winget | |
$progressPreference = 'silentlyContinue' | |
Write-Host "Installing WinGet PowerShell module from PSGallery..." | |
Install-PackageProvider -Name NuGet -Force | Out-Null | |
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null | |
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..." | |
Repair-WinGetPackageManager | |
Write-Host "Done." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix wmi | |
winmgmt /resetrepository | |
Restart-Service Winmgmt | |
Get-CimInstance -Namespace root/cimv2 -ClassName Win32_PingStatus -Filter "Address='www.microsoft.com'" | |
# disable Delivery Optimization | |
Stop-Service DoSvc | |
$backupReg = "C:\Windows\Temp\DoSvc.reg" | |
$regPath = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DoSvc" | |
reg export $regPath $backupReg /y | |
reg delete $regPath /f | |
# install winget | |
$progressPreference = 'silentlyContinue' | |
Write-Host "Installing WinGet PowerShell module from PSGallery..." | |
Install-PackageProvider -Name NuGet -Force | Out-Null | |
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null | |
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..." | |
Repair-WinGetPackageManager | |
Write-Host "Done." | |
# restore DoSvc | |
reg import $backupReg | |
rm $backupReg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment