0% found this document useful (0 votes)
4 views2 pages

DotNet+VC++ ps1

1

Uploaded by

6649s7rsmf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

DotNet+VC++ ps1

1

Uploaded by

6649s7rsmf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

$host.ui.RawUI.

BackgroundColor = "Black"
$host.ui.RawUI.ForegroundColor = "White"
Clear-Host

# Vérifier les privilèges administratifs


function Check-Admin {
Write-Host "Checking for Administrative Privileges..."
Start-Sleep -Seconds 3

$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
if (-not
$principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process powershell -Verb runAs -ArgumentList "-NoProfile -
ExecutionPolicy Bypass -File `"$PSCommandPath`""
exit
}
}
Check-Admin

# Vérification de l'installation de Winget


if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Host "Winget is not installed. Loading installation..."
Set-ExecutionPolicy Bypass -Scope Process -Force;
Invoke-WebRequest -Uri
"https://github.com/microsoft/winget-cli/releases/download/v1.9.25170/
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile "$env:TEMP\
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
Add-AppxPackage -Path "$env:TEMP\
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
}

# List of .NET runtimes


$netRuntimes = @(
"Microsoft.DotNet.Runtime.3_1",
"Microsoft.DotNet.Runtime.5",
"Microsoft.DotNet.Runtime.6",
"Microsoft.DotNet.Runtime.7",
"Microsoft.DotNet.Runtime.8"
)

# List of Visual C++ runtimes


$vcRuntimes = @(
"Microsoft.VCRedist.2005.x86",
"Microsoft.VCRedist.2005.x64",
"Microsoft.VCRedist.2008.x86",
"Microsoft.VCRedist.2008.x64",
"Microsoft.VCRedist.2010.x86",
"Microsoft.VCRedist.2010.x64",
"Microsoft.VCRedist.2012.x86",
"Microsoft.VCRedist.2012.x64",
"Microsoft.VCRedist.2013.x86",
"Microsoft.VCRedist.2013.x64",
"Microsoft.VCRedist.2015.x86",
"Microsoft.VCRedist.2015.x64",
"Microsoft.VCRedist.2017.x86",
"Microsoft.VCRedist.2017.x64",
"Microsoft.VCRedist.2019.x86",
"Microsoft.VCRedist.2019.x64"
)

# Install .NET runtimes


foreach ($runtime in $netRuntimes) {
Write-Host "Installing $runtime..." -ForegroundColor Yellow
winget install --id $runtime --silent --accept-package-agreements --accept-
source-agreements
}

# Install Visual C++ runtimes


foreach ($runtime in $vcRuntimes) {
Write-Host "Installing $runtime..." -ForegroundColor Yellow
winget install --id $runtime --silent --accept-package-agreements --accept-
source-agreements
}

Write-Host "All runtimes have been successfully installed." -ForegroundColor Green

You might also like