@echo off
:: Check for Administrator privileges
?? admin privs
openfiles >nul 2>&1
if %errorlevel% neq 0 (
echo Requesting administrative privileges...
powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b
)
echo ====================================================
echo Installing WinGet (Windows Package Manager)
echo ====================================================
:: Set execution policy and use PowerShell to download/install WinGet and its dependencies
powershell -NoProfile -ExecutionPolicy Bypass -Command "^
$ProgressPreference = 'SilentlyContinue'; ^
echo 'Downloading VCLibs dependency...'; ^
Invoke-WebRequest -Uri 'https://aka.ms' -OutFile '$env:TEMP\VCLibs.appx'; ^
echo 'Downloading UI.Xaml dependency...'; ^
Invoke-WebRequest -Uri 'https://github.com' -OutFile '$env:TEMP\UI.Xaml.appx'; ^
echo 'Downloading latest WinGet bundle...'; ^
Invoke-WebRequest -Uri 'https://github.com' -OutFile '$env:TEMP\WinGet.msixbundle'; ^
echo 'Installing VCLibs...'; ^
Add-AppxPackage -Path '$env:TEMP\VCLibs.appx'; ^
echo 'Installing UI.Xaml...'; ^
Add-AppxPackage -Path '$env:TEMP\UI.Xaml.appx'; ^
echo 'Installing WinGet (App Installer)...'; ^
Add-AppxPackage -Path '$env:TEMP\WinGet.msixbundle'; ^
echo 'Cleaning up temp files...'; ^
Remove-Item '$env:TEMP\VCLibs.appx', '$env:TEMP\UI.Xaml.appx', '$env:TEMP\WinGet.msixbundle' -ErrorAction SilentlyContinue; ^
"
echo ====================================================
echo Verifying WinGet Installation
echo ====================================================
:: Refresh environment path variables for the current session
set "PATH=%LOCALAPPDATA%\Microsoft\WindowsApps;%PATH%"
winget --version >nul 2>&1
if %errorlevel% equ 0 (
echo Success! WinGet is installed.
winget --version
) else (
echo Installation failed or system requires a reboot to refresh environment variables.
)
pause