# --- Win10 Setup Script (Safe + Reversible) --- # Save original UAC setting so we can restore later $originalUAC = Get-ItemPropertyValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" # Save sideloading state $appxKey = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Appx" if (-not (Test-Path $appxKey)) { New-Item -Path $appxKey -Force | Out-Null } $originalTrustedApps = (Get-ItemProperty -Path $appxKey -ErrorAction SilentlyContinue).AllowAllTrustedApps $originalDevLicense = (Get-ItemProperty -Path $appxKey -ErrorAction SilentlyContinue).AllowDevelopmentWithoutDevLicense # --- Disable UAC (temporarily) --- try { Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 0 -ErrorAction Stop Write-Host "UAC prompt behavior disabled temporarily." -ForegroundColor Yellow } catch { Write-Warning "Failed to modify UAC setting: $_" } # --- Enable sideloading (temporarily) --- try { Set-ItemProperty -Path $appxKey -Name AllowAllTrustedApps -Value 1 -Force Set-ItemProperty -Path $appxKey -Name AllowDevelopmentWithoutDevLicense -Value 1 -Force Write-Host "Enabled sideloading temporarily." -ForegroundColor Yellow } catch { Write-Warning "Failed to enable sideloading: $_" } # --- Ensure Winget Installed --- try { winget --version > $null Write-Host "Winget already installed." -ForegroundColor Cyan } catch { Write-Host "Winget not found. Installing..." -ForegroundColor Yellow $ProgressPreference = 'SilentlyContinue' # Dependencies Invoke-WebRequest -Uri "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" -OutFile "VCLibs.appx" Add-AppxPackage "VCLibs.appx" # Latest Microsoft.UI.Xaml (2.8.x) Invoke-WebRequest -Uri "https://github.com/microsoft/microsoft-ui-xaml/releases/latest/download/Microsoft.UI.Xaml.2.8.x64.appx" -OutFile "UI.Xaml.appx" Add-AppxPackage "UI.Xaml.appx" # WinGet Invoke-WebRequest -Uri "https://aka.ms/getwinget" -OutFile "winget.msixbundle" Add-AppxPackage "winget.msixbundle" # Verify if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { Write-Host "Winget installation failed. Opening Microsoft Store for manual install..." -ForegroundColor Red Start-Process "ms-windows-store://pdp/?productid=9NBLGGH4NNS1" Pause } else { Write-Host "Winget installed successfully." -ForegroundColor Green } } # --- Define Packages --- $packages = @( "Valve.Steam", "VideoLAN.VLC", "Mozilla.Firefox", "Spotify.Spotify", "Oracle.JavaRuntimeEnvironment", "Oracle.JDK.19", "Git.Git", "RARLab.WinRAR", "Microsoft.DotNet.SDK.8", "Microsoft.DotNet.Runtime.7", "Discord.Discord", "Microsoft.VisualStudioCode", "qBittorrent.qBittorrent", "Neovim.Neovim" ) # --- Install Packages --- foreach ($id in $packages) { Write-Host "Installing $id..." -ForegroundColor Cyan winget install --id $id --accept-package-agreements --accept-source-agreements --silent -e } # --- Optional: Run Windows Debloater (comment if not needed) --- try { irm "https://raw.githubusercontent.com/Sycnex/Windows10Debloater/master/Windows10Debloater.ps1" | iex } catch { Write-Warning "Windows10Debloater failed: $_" } # --- Optional: Activation script (⚠️ caution, not MS-approved) --- try { irm https://get.activated.win | iex } catch { Write-Warning "Activation script failed: $_" } # --- Restore Settings --- try { # Restore UAC Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value $originalUAC Write-Host "UAC setting restored." -ForegroundColor Green # Restore sideloading settings if ($null -ne $originalTrustedApps) { Set-ItemProperty -Path $appxKey -Name AllowAllTrustedApps -Value $originalTrustedApps } else { Remove-ItemProperty -Path $appxKey -Name AllowAllTrustedApps -ErrorAction SilentlyContinue } if ($null -ne $originalDevLicense) { Set-ItemProperty -Path $appxKey -Name AllowDevelopmentWithoutDevLicense -Value $originalDevLicense } else { Remove-ItemProperty -Path $appxKey -Name AllowDevelopmentWithoutDevLicense -ErrorAction SilentlyContinue } Write-Host "Sideloading settings restored." -ForegroundColor Green } catch { Write-Warning "Failed to restore original settings: $_" } Clear-Host Write-Host "✅ Finished setup. System settings restored." -ForegroundColor Green Pause