From 42ea1ab7f3e4ce15045ddb1e966393c604a2f437 Mon Sep 17 00:00:00 2001 From: Carterpersall Date: Sat, 23 Apr 2022 12:05:45 -0500 Subject: [PATCH 1/2] Add alternative winget install win10debloat.ps1: - Fixes #229, the normal winget installation method does not work for LTSC and Server versions of windows due to the lack of both Windows Package Manager and the VCLibs dependency. The current fix implements the method shown at microsoft/winget-cli#1956 which installs everything manually. --- win10debloat.ps1 | 60 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/win10debloat.ps1 b/win10debloat.ps1 index 741c1fc3..ecc738c6 100644 --- a/win10debloat.ps1 +++ b/win10debloat.ps1 @@ -11,21 +11,57 @@ If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]: } # GUI Specs -Write-Host "Checking winget..." # Check if winget is installed +Write-Host "Checking if Winget is Installed..." if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ - 'Winget Already Installed' -} -else{ - # Installing winget from the Microsoft Store - Write-Host "Winget not found, installing it now." - $ResultText.text = "`r`n" +"`r`n" + "Installing Winget... Please Wait" - Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" - $nid = (Get-Process AppInstaller).Id - Wait-Process -Id $nid - Write-Host Winget Installed - $ResultText.text = "`r`n" +"`r`n" + "Winget Installed - Ready for Next Task" + Write-Host "Winget Already Installed" +}else{ + if(((((Get-ComputerInfo).OSName.IndexOf("LTSC")) -ne -1) -or ((Get-ComputerInfo).OSName.IndexOf("Server") -ne -1)) -and (((Get-ComputerInfo).WindowsVersion) -ge "1809")){#Checks if Windows edition is LTSC 2019+ + #Manually Installing Winget + Write-Host "Running Alternative Installer for LTSC/Server Editions" + $ResultText.Text = "`r`n" +"`r`n" + "Running Alternative Installer for LTSC/Server Editions" + + #Download Needed Files + Write-Host "Downloading Needed Files..." + $ResultText.Text = "`r`n" +"`r`n" + "Downloading Needed Files..." + Start-BitsTransfer -Source "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" -Destination "./Microsoft.VCLibs.x64.14.00.Desktop.appx" + Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Destination "./Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" + Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/b0a0692da1034339b76dce1c298a1e42_License1.xml" -Destination "./b0a0692da1034339b76dce1c298a1e42_License1.xml" + + #Installing Packages + Write-Host "Installing Packages..." + $ResultText.Text = "`r`n" +"`r`n" + "Installing Packages..." + Add-AppxProvisionedPackage -Online -PackagePath ".\Microsoft.VCLibs.x64.14.00.Desktop.appx" -SkipLicense + Add-AppxProvisionedPackage -Online -PackagePath ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -LicensePath ".\b0a0692da1034339b76dce1c298a1e42_License1.xml" + Write-Host "winget Installed (Reboot might be required before winget will work)" + $ResultText.Text = "`r`n" +"`r`n" + "winget Installed (Reboot might be required before winget will work)" + + #Sleep for 5 seconds to maximize chance that winget will work without reboot + Write-Host "Sleeping for 5 seconds to maximize chance that winget will work without reboot" + $ResultText.Text = "`r`n" +"`r`n" + "Sleeping for 5 seconds to maximize chance that winget will work without reboot" + Start-Sleep -s 5 + + #Removing Unneeded Files + Write-Host "Removing Unneeded Files..." + $ResultText.Text = "`r`n" +"`r`n" + "Removing Unneeded Files..." + Remove-Item -Path ".\Microsoft.VCLibs.x64.14.00.Desktop.appx" -Force + Remove-Item -Path ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force + Remove-Item -Path ".\b0a0692da1034339b76dce1c298a1e42_License1.xml" -Force + Write-Host "Unneeded Files Removed" + $ResultText.Text = "`r`n" +"`r`n" + "Unneeded Files Removed" + }elseif(((Get-ComputerInfo).WindowsVersion) -lt "1809"){#Checks if Windows Version is too old for winget + Write-Host "Winget is not supported on this version of Windows" + }else{ + #Installing Winget from the Microsoft Store + Write-Host "Winget not found, installing it now." + $ResultText.text = "`r`n" +"`r`n" + "Installing Winget..." + Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" + $nid = (Get-Process AppInstaller).Id + Wait-Process -Id $nid + Write-Host "Winget Installed" + $ResultText.text = "`r`n" +"`r`n" + "Winget Installed" + } } $Form = New-Object system.Windows.Forms.Form From 3b63282c031336c60cbf87ce21742f45d8c5f8e9 Mon Sep 17 00:00:00 2001 From: Carterpersall Date: Sat, 23 Apr 2022 12:12:40 -0500 Subject: [PATCH 2/2] Change some wording Changed the wording of some comments and added a comment --- win10debloat.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/win10debloat.ps1 b/win10debloat.ps1 index ecc738c6..bb5d39ed 100644 --- a/win10debloat.ps1 +++ b/win10debloat.ps1 @@ -14,7 +14,7 @@ If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]: # Check if winget is installed Write-Host "Checking if Winget is Installed..." -if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ +if ((Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe) -and (((Get-ComputerInfo).WindowsVersion) -ge "1809")){ #Checks if winget executable exists and if the Windows Version is 1809 or higher Write-Host "Winget Already Installed" }else{ if(((((Get-ComputerInfo).OSName.IndexOf("LTSC")) -ne -1) -or ((Get-ComputerInfo).OSName.IndexOf("Server") -ne -1)) -and (((Get-ComputerInfo).WindowsVersion) -ge "1809")){#Checks if Windows edition is LTSC 2019+ @@ -38,20 +38,20 @@ if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ $ResultText.Text = "`r`n" +"`r`n" + "winget Installed (Reboot might be required before winget will work)" #Sleep for 5 seconds to maximize chance that winget will work without reboot - Write-Host "Sleeping for 5 seconds to maximize chance that winget will work without reboot" - $ResultText.Text = "`r`n" +"`r`n" + "Sleeping for 5 seconds to maximize chance that winget will work without reboot" + Write-Host "Pausing for 5 seconds to maximize chance that winget will work without reboot" + $ResultText.Text = "`r`n" +"`r`n" + "Pausing for 5 seconds to maximize chance that winget will work without reboot" Start-Sleep -s 5 - #Removing Unneeded Files - Write-Host "Removing Unneeded Files..." - $ResultText.Text = "`r`n" +"`r`n" + "Removing Unneeded Files..." + #Removing no longer needed Files + Write-Host "Removing no longer needed Files..." + $ResultText.Text = "`r`n" +"`r`n" + "Removing no longer needed Files..." Remove-Item -Path ".\Microsoft.VCLibs.x64.14.00.Desktop.appx" -Force Remove-Item -Path ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force Remove-Item -Path ".\b0a0692da1034339b76dce1c298a1e42_License1.xml" -Force - Write-Host "Unneeded Files Removed" - $ResultText.Text = "`r`n" +"`r`n" + "Unneeded Files Removed" - }elseif(((Get-ComputerInfo).WindowsVersion) -lt "1809"){#Checks if Windows Version is too old for winget - Write-Host "Winget is not supported on this version of Windows" + Write-Host "Removed Files no longer needed" + $ResultText.Text = "`r`n" +"`r`n" + "Removed Files no longer needed" + }elseif(((Get-ComputerInfo).WindowsVersion) -lt "1809"){ #Checks if Windows Version is too old for winget + Write-Host "Winget is not supported on this version of Windows (Pre-1809)" }else{ #Installing Winget from the Microsoft Store Write-Host "Winget not found, installing it now."