Skip to content

Instantly share code, notes, and snippets.

@skrimix
Created August 4, 2022 00:21
Show Gist options
  • Save skrimix/3f820e5645b0e87a4098e55af3377180 to your computer and use it in GitHub Desktop.
Save skrimix/3f820e5645b0e87a4098e55af3377180 to your computer and use it in GitHub Desktop.
@echo off
:Start
setlocal DisableDelayedExpansion
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
set "n=1>NUL 2>NUL"
title HFP's Redist Installer 3.0
color 1b
echo ============================
echo HFP's Redists Installer 3.00
echo ============================
echo NET / VC++ / XNA / 7Zip / DX
echo.
echo NOTE:
echo ----------------------------
echo Unlike older versions, this
echo version should stay relevant
echo due to the fact that it just
echo gets all currently available
echo .NET / VC++ redristibutables
echo ----------------------------
echo.
echo.
echo If this still doesn't work -
echo try DISM/SFC/Delete Antivirus
echo /install Windows Updates...
echo.
echo -or just reinstall Windows :(
pause
cls
echo ============================
echo Installing VC Redists...
echo ============================
echo.
Timeout /t 4 /nobreak 1>nul 2>nul
setlocal ENABLEDELAYEDEXPANSION
winget search Microsoft.VC --accept-source-agreements >NUL 2>NUL
FOR /F "tokens=*" %%G IN ('winget search Microsoft.VC') DO (
set "str=%%G"
set "str=!str:*Microsoft.=Microsoft.!"
for /f "tokens=1 delims= " %%a in ("!str!") do (
echo %%a | FIND /I "Microsoft." 1>nul 2>Nul && (
call :GET %%a
)
)
)
endlocal
)
cls
echo ============================
echo + VC Redists Installed +
echo ============================
echo.
Timeout /t 2 /nobreak 1>nul 2>nul
cls
echo ============================
echo Installing .NET Redists...
echo ============================
echo.
Timeout /t 2 /nobreak 1>nul 2>nul
setlocal ENABLEDELAYEDEXPANSION
FOR /F "tokens=*" %%G IN ('winget search Microsoft.dotNet') DO (
set /a skip=0
set "str=%%G"
set "str=!str:*Microsoft.=Microsoft.!"
for /f "tokens=1 delims= " %%a in ("!str!") do (
echo %%a | FIND /I "Microsoft.dotnetUninstallTool" 1>nul 2>Nul && (set /a skip=1)
echo %%a | FIND /I "Microsoft.DotNet.HostingBundle" 1>nul 2>Nul && (set /a skip=1)
echo %%a | FIND /I "Microsoft." 1>nul 2>Nul && (
if "!skip!" == "0" (
call :GET %%a
)
)
)
)
endlocal
goto :finished
:GET outer
echo Installing %1... 2>nul
winget install -e --id %1 --accept-package-agreements --accept-source-agreements --force 2>nul 1>nul
goto :eol
:finished
cls
echo ============================
echo + Installed .Net redists +
echo ============================
echo.
Timeout /t 2 /nobreak 1>nul 2>nul
cls
echo ============================
echo Installing common tools...
echo ============================
echo.
Timeout /t 2 /nobreak 1>nul 2>nul
REM Install some other loose ends.
echo DirectX
winget install -e --id Microsoft.DirectX --accept-package-agreements --accept-source-agreements --force --silent 2>nul 1>nul
echo XNA Framework Redistributable
winget install -e --id Microsoft.XNARedist --accept-package-agreements --accept-source-agreements --force --silent 2>nul 1>nul
echo VLC Media Player
winget install -e --id VideoLAN.VLC --accept-package-agreements --accept-source-agreements --force 2>nul 1>nul
echo 7zip
winget install -e --id 7zip.7zip --accept-package-agreements --accept-source-agreements --force --silent 2>nul 1>nul
echo Powershell
winget install -e --id Microsoft.PowerShell --accept-package-agreements --accept-source-agreements --force --silent 2>nul 1>nul
Timeout /t 2 /nobreak 1>nul 2>nul
cls
echo ============================
echo + Installed Common Tools +
echo ============================
echo.
Timeout /t 2 /nobreak 1>nul 2>nul
cls
echo All done. Press any key to exit.
pause > nul
:eol
Function Test-CommandExists
{
Param ($command)
try {if(Get-Command $command){RETURN $true}}
Catch {RETURN $false}
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
$ErrorActionPreference = 'stop'
if (!(Test-CommandExists winget))
{
echo "Installing latest winget..."
$DownloadURL = 'https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
$FilePath = "$env:TEMP\WinGet.msixbundle"
try {
Invoke-WebRequest -Uri $DownloadURL -UseBasicParsing -OutFile $FilePath
} catch {
Write-Error $_
Return
}
if (Test-Path $FilePath) {
Add-AppxPackage $FilePath
$item = Get-Item -LiteralPath $FilePath
$item.Delete()
}
}
echo "Downloading script..."
$DownloadURL = 'https://gist.githubusercontent.com/skrimix/3f820e5645b0e87a4098e55af3377180/raw/redists.cmd'
$FilePath = "$env:TEMP\redists.cmd"
try {
Invoke-WebRequest -Uri $DownloadURL -UseBasicParsing -OutFile $FilePath
} catch {
Write-Error $_
Return
}
if (Test-Path $FilePath) {
Start-Process -Verb runAs $FilePath -Wait
$item = Get-Item -LiteralPath $FilePath
$item.Delete()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment