@echo off setlocal cd /d "%~dp0" title Microsoft Manager 2026 By Akshat_530 :: 1. DETECT POWERSHELL VERSION set "PS_CMD=powershell" where pwsh >nul 2>&1 if %errorLevel% equ 0 (set "PS_CMD=pwsh") :: 2. CHECK FOR ADMIN RIGHTS net session >nul 2>&1 if %errorLevel% neq 0 ( echo Requesting administrative privileges... %PS_CMD% -NoProfile -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', '\"\"%~f0\"\"' -Verb RunAs" exit /b ) :: 3. EXECUTE POWERSHELL PORTION %PS_CMD% -NoProfile -ExecutionPolicy Bypass -Command ^ "$s=[scriptblock]::Create((Get-Content '%~f0' | Where-Object { $found -or $_ -match '^\$ErrorActionPreference' } | ForEach-Object { $found=$true; $_ } | Out-String)); & $s" exit /b $ErrorActionPreference = "Stop" $ProgressPreference = 'SilentlyContinue' # Visual verification Write-Host "Running on: $($PSVersionTable.PSVersion)" -ForegroundColor DarkGray Write-Host "User Context: $([Security.Principal.WindowsIdentity]::GetCurrent().Name)" -ForegroundColor DarkGray Write-Host "------------------------------------------------" # Setup temp directory $TempDir = "$env:TEMP\Microsoft_Manager_2026" if (!(Test-Path $TempDir)) { New-Item -ItemType Directory -Force -Path $TempDir | Out-Null } # ----------------------------------------------------- # Helper Functions # ----------------------------------------------------- function Test-IsInstalled { param ([string]$NameRegex, [string]$ArchRegex) $Paths = @( "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" ) $Keys = Get-ItemProperty $Paths -ErrorAction SilentlyContinue $Found = $Keys | Where-Object { $_.DisplayName -match $NameRegex -and ($_.DisplayName -match $ArchRegex -or $_.PSChildName -match $ArchRegex -or $_.UninstallString -match $ArchRegex) } return [bool]$Found } function Test-DotNetInstalled { param ([string]$Ver, [string]$Type, [string]$Arch) $BaseDir = if ($Arch -eq "x86") { ${env:ProgramFiles(x86)} } else { $env:ProgramFiles } if ([string]::IsNullOrWhiteSpace($BaseDir)) { $BaseDir = if ($Arch -eq "x86") { "C:\Program Files (x86)" } else { "C:\Program Files" } } $TargetFolder = if ($Type -eq "sdk") { "$BaseDir\dotnet\sdk" } else { "$BaseDir\dotnet\shared\Microsoft.NETCore.App" } if (Test-Path $TargetFolder) { $Versions = Get-ChildItem -Path $TargetFolder -Directory | Select-Object -ExpandProperty Name foreach ($InstalledVer in $Versions) { if ($InstalledVer -match "^$Ver\.") { return $true } } } return $false } function Install-Component { param ( [string]$Label, [string]$Url, [string]$InstallArgs, [scriptblock]$CheckLogic ) if (&$CheckLogic) { Write-Host "[SKIP] $Label is already installed or up-to-date." -ForegroundColor DarkGray return } $CleanLabel = $Label -replace '[^a-zA-Z0-9]','_' $File = Join-Path $TempDir "$($CleanLabel).exe" if ([string]::IsNullOrWhiteSpace($InstallArgs)) { $InstallArgs = "/passive /norestart" } try { Write-Host "[~] Downloading $Label..." -NoNewline -ForegroundColor Cyan Invoke-WebRequest -Uri $Url -OutFile $File -ErrorAction Stop Write-Host " Done." -ForegroundColor Green Write-Host "[+] Installing $Label..." -ForegroundColor Cyan $Process = Start-Process -FilePath $File -ArgumentList $InstallArgs -Wait -PassThru if ($Process.ExitCode -eq 0 -or $Process.ExitCode -eq 3010 -or $Process.ExitCode -eq 1638) { Write-Host "[SUCCESS] $Label processed successfully." -ForegroundColor Green } else { Write-Host "[WARNING] $Label finished with exit code: $($Process.ExitCode)." -ForegroundColor Yellow } } catch { Write-Host "[ERROR] Failed to process ${Label}: $($_.Exception.Message)" -ForegroundColor Red } finally { if (Test-Path $File) { Remove-Item $File -Force -ErrorAction SilentlyContinue } } } function Uninstall-Target { param ([string]$NameRegex) Write-Host "`n[*] Searching for installed components matching: '$NameRegex'..." -ForegroundColor Cyan $Paths = @( "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" ) $Items = Get-ItemProperty $Paths -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -match $NameRegex } if (-not $Items) { Write-Host "[-] No components found matching '$NameRegex'." -ForegroundColor DarkGray return } foreach ($Item in $Items) { $DisplayName = $Item.DisplayName $UninstallString = $Item.QuietUninstallString # Fallback to standard uninstall string if quiet is missing if ([string]::IsNullOrWhiteSpace($UninstallString)) { $UninstallString = $Item.UninstallString } if ([string]::IsNullOrWhiteSpace($UninstallString)) { Write-Host "[!] No uninstall string found for '$DisplayName'. Skipping." -ForegroundColor Yellow continue } Write-Host "[~] Uninstalling: $DisplayName" -ForegroundColor Yellow # Safely format the uninstall string for silent execution $US = $UninstallString -replace "/I", "/X" -replace "/i", "/x" if ($US -match "msiexec") { if ($US -notmatch "/quiet" -and $US -notmatch "/qn") { $US += " /quiet /norestart" } } else { if ($US -notmatch "/quiet" -and $US -notmatch "/q") { $US += " /uninstall /quiet /norestart" } } try { $Process = Start-Process -FilePath "cmd.exe" -ArgumentList "/c `"$US`"" -Wait -PassThru -WindowStyle Hidden if ($Process.ExitCode -eq 0 -or $Process.ExitCode -eq 3010 -or $Process.ExitCode -eq 1605 -or $Process.ExitCode -eq 1614) { Write-Host " [SUCCESS] Uninstalled." -ForegroundColor Green } else { Write-Host " [WARNING] Finished with exit code: $($Process.ExitCode)" -ForegroundColor Red } } catch { Write-Host " [ERROR] Failed to execute uninstaller." -ForegroundColor Red } } } # ----------------------------------------------------- # Installation Modules # ----------------------------------------------------- function Install-DirectX { Write-Host "`n--- DirectX End-User Runtimes (Legacy Support) ---" -ForegroundColor Yellow $DxCheck = { (Test-Path "$env:SystemRoot\System32\d3dx9_43.dll") -and (Test-Path "$env:SystemRoot\SysWOW64\d3dx9_43.dll") } $DxUrl = "https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe" Install-Component -Label "DirectX Legacy Runtimes" -Url $DxUrl -InstallArgs "/q" -CheckLogic $DxCheck } function Install-VCRedists { Write-Host "`n--- Visual C++ Redistributables (2005 - 2026) ---" -ForegroundColor Yellow $VCList = @( @{ L="VC++ 2005 x86"; U="https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.exe"; A="/q"; C={Test-IsInstalled "Visual C\+\+ 2005" "x86"} }, @{ L="VC++ 2005 x64"; U="https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x64.exe"; A="/q"; C={Test-IsInstalled "Visual C\+\+ 2005" "x64"} }, @{ L="VC++ 2008 x86"; U="https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe"; A="/q"; C={Test-IsInstalled "Visual C\+\+ 2008" "x86"} }, @{ L="VC++ 2008 x64"; U="https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x64.exe"; A="/q"; C={Test-IsInstalled "Visual C\+\+ 2008" "x64"} }, @{ L="VC++ 2010 x86"; U="https://download.microsoft.com/download/C/6/D/C6D0FD4E-9E53-4897-9B91-836EBA2AACD3/vcredist_x86.exe"; A="/passive /norestart"; C={Test-IsInstalled "Visual C\+\+ 2010" "x86"} }, @{ L="VC++ 2010 x64"; U="https://download.microsoft.com/download/A/8/0/A80747C3-41BD-45DF-B505-E9710D2744E0/vcredist_x64.exe"; A="/passive /norestart"; C={Test-IsInstalled "Visual C\+\+ 2010" "x64"} }, @{ L="VC++ 2012 x86"; U="https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe"; A="/passive /norestart"; C={Test-IsInstalled "Visual C\+\+ 2012" "x86"} }, @{ L="VC++ 2012 x64"; U="https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe"; A="/passive /norestart"; C={Test-IsInstalled "Visual C\+\+ 2012" "x64"} }, @{ L="VC++ 2013 x86"; U="https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe"; A="/passive /norestart"; C={Test-IsInstalled "Visual C\+\+ 2013" "x86"} }, @{ L="VC++ 2013 x64"; U="https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe"; A="/passive /norestart"; C={Test-IsInstalled "Visual C\+\+ 2013" "x64"} }, @{ L="VC++ v14 x86 (2015-2026)"; U="https://aka.ms/vc14/vc_redist.x86.exe"; A="/passive /norestart"; C={$false} }, @{ L="VC++ v14 x64 (2015-2026)"; U="https://aka.ms/vc14/vc_redist.x64.exe"; A="/passive /norestart"; C={$false} } ) foreach ($item in $VCList) { Install-Component -Label $item.L -Url $item.U -InstallArgs $item.A -CheckLogic $item.C } } function Install-DotNetSDKs { Write-Host "`n--- .NET SDKs (Versions 5 - 10) ---" -ForegroundColor Yellow foreach ($v in 5..10) { $vStr = "$v.0" Install-Component -Label ".NET SDK $vStr x64" -Url "https://aka.ms/dotnet/$vStr/dotnet-sdk-win-x64.exe" -InstallArgs "/quiet /norestart" -CheckLogic { Test-DotNetInstalled "$v" "sdk" "x64" } Install-Component -Label ".NET SDK $vStr x86" -Url "https://aka.ms/dotnet/$vStr/dotnet-sdk-win-x86.exe" -InstallArgs "/quiet /norestart" -CheckLogic { Test-DotNetInstalled "$v" "sdk" "x86" } } } function Install-AspNet { Write-Host "`n--- ASP.NET Core Runtimes (Versions 5 - 10) ---" -ForegroundColor Yellow foreach ($v in 5..10) { $vStr = "$v.0" Install-Component -Label "ASP.NET Core $vStr x64" -Url "https://aka.ms/dotnet/$vStr/aspnetcore-runtime-win-x64.exe" -InstallArgs "/quiet /norestart" -CheckLogic { Test-DotNetInstalled "$v" "runtime" "x64" } Install-Component -Label "ASP.NET Core $vStr x86" -Url "https://aka.ms/dotnet/$vStr/aspnetcore-runtime-win-x86.exe" -InstallArgs "/quiet /norestart" -CheckLogic { Test-DotNetInstalled "$v" "runtime" "x86" } } } function Uninstall-AllVCRedist { Write-Host "`n--- Uninstalling Visual C++ Redistributables ---" -ForegroundColor Red Uninstall-Target -NameRegex "Visual C\+\+" } function Uninstall-AllDotNet { Write-Host "`n--- Uninstalling .NET & ASP.NET Runtimes/SDKs ---" -ForegroundColor Red Uninstall-Target -NameRegex "Microsoft \.NET (SDK|Runtime)|ASP\.NET Core|Windows Desktop Runtime" } # ----------------------------------------------------- # Main Execution Loop # ----------------------------------------------------- while ($true) { Clear-Host Write-Host "===============================================" -ForegroundColor Cyan Write-Host " MICROSOFT MANAGER 2026 by Akshat_530 " -ForegroundColor White Write-Host "===============================================" -ForegroundColor Cyan Write-Host "1. Install DirectX" Write-Host "2. Install VC++ Redistributables (2005 - 2026)" Write-Host "3. Install .NET SDKs (5 - 10)" Write-Host "4. Install ASP.NET Core Runtimes (5 - 10)" Write-Host "-----------------------------------------------" -ForegroundColor DarkGray Write-Host "5. UNINSTALL ALL VC++ Redistributables" -ForegroundColor Red Write-Host "6. UNINSTALL ALL .NET SDKs & Runtimes" -ForegroundColor Red Write-Host "-----------------------------------------------" -ForegroundColor DarkGray Write-Host "Q. Quit" Write-Host "" $Choice = Read-Host "Select an option" switch ($Choice) { "1" { Install-DirectX } "2" { Install-VCRedists } "3" { Install-DotNetSDKs } "4" { Install-AspNet } "5" { Uninstall-AllVCRedist } "6" { Uninstall-AllDotNet } "q" { Write-Host "`nCleaning up temp files and exiting..." if (Test-Path $TempDir) { Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinue } exit } "Q" { Write-Host "`nCleaning up temp files and exiting..." if (Test-Path $TempDir) { Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinue } exit } default { Write-Host "Invalid selection. Please try again." -ForegroundColor Red } } Write-Host "`nOperation finished. Press any key to return to the menu..." -ForegroundColor Cyan $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") }