├── Drivers ├── RAID │ ├── Optane.dll │ ├── iaStorAC.cat │ ├── iaStorAC.inf │ ├── iaStorAC.sys │ ├── iaStorAfs.sys │ ├── RstMwService.exe │ ├── RstMwEventLogMsg.dll │ ├── iaStorAfsNative.exe │ ├── iaStorAfsService.exe │ ├── HfcDisableService.exe │ └── OptaneEventLogMsg.dll ├── VMD │ ├── Optane.dll │ ├── iaStorAfs.sys │ ├── iaStorVD.cat │ ├── iaStorVD.inf │ ├── iaStorVD.sys │ ├── RstMwService.exe │ ├── iaStorAfsNative.exe │ ├── OptaneEventLogMsg.dll │ ├── RstMwEventLogMsg.dll │ └── iaStorAfsService.exe └── README.md ├── .github └── workflows │ ├── add-release-asset.yml │ └── doRelease.ps1 ├── download.ps1 ├── autounattend.xml ├── README.md ├── LICENSE └── isoDebloaterScript.ps1 /Drivers/RAID/Optane.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/Optane.dll -------------------------------------------------------------------------------- /Drivers/VMD/Optane.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/Optane.dll -------------------------------------------------------------------------------- /Drivers/RAID/iaStorAC.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/iaStorAC.cat -------------------------------------------------------------------------------- /Drivers/RAID/iaStorAC.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/iaStorAC.inf -------------------------------------------------------------------------------- /Drivers/RAID/iaStorAC.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/iaStorAC.sys -------------------------------------------------------------------------------- /Drivers/RAID/iaStorAfs.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/iaStorAfs.sys -------------------------------------------------------------------------------- /Drivers/VMD/iaStorAfs.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/iaStorAfs.sys -------------------------------------------------------------------------------- /Drivers/VMD/iaStorVD.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/iaStorVD.cat -------------------------------------------------------------------------------- /Drivers/VMD/iaStorVD.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/iaStorVD.inf -------------------------------------------------------------------------------- /Drivers/VMD/iaStorVD.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/iaStorVD.sys -------------------------------------------------------------------------------- /Drivers/VMD/RstMwService.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/RstMwService.exe -------------------------------------------------------------------------------- /Drivers/RAID/RstMwService.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/RstMwService.exe -------------------------------------------------------------------------------- /Drivers/VMD/iaStorAfsNative.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/iaStorAfsNative.exe -------------------------------------------------------------------------------- /Drivers/RAID/RstMwEventLogMsg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/RstMwEventLogMsg.dll -------------------------------------------------------------------------------- /Drivers/RAID/iaStorAfsNative.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/iaStorAfsNative.exe -------------------------------------------------------------------------------- /Drivers/RAID/iaStorAfsService.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/iaStorAfsService.exe -------------------------------------------------------------------------------- /Drivers/VMD/OptaneEventLogMsg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/OptaneEventLogMsg.dll -------------------------------------------------------------------------------- /Drivers/VMD/RstMwEventLogMsg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/RstMwEventLogMsg.dll -------------------------------------------------------------------------------- /Drivers/VMD/iaStorAfsService.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/VMD/iaStorAfsService.exe -------------------------------------------------------------------------------- /Drivers/RAID/HfcDisableService.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/HfcDisableService.exe -------------------------------------------------------------------------------- /Drivers/RAID/OptaneEventLogMsg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/HEAD/Drivers/RAID/OptaneEventLogMsg.dll -------------------------------------------------------------------------------- /Drivers/README.md: -------------------------------------------------------------------------------- 1 | ## About These Drivers 2 | 3 | The driver packages in this directory were extracted directly from the official Intel Rapid Storage Technology (RST) installer, available at: 4 | 5 | 6 | 7 | Extraction was performed using the following command: 8 | 9 | ``` 10 | SetupRST.exe -extractdrivers 11 | ``` 12 | 13 | These drivers are provided here exactly as extracted, without any modification. All files and associated intellectual property are the sole property of Intel Corporation. 14 | -------------------------------------------------------------------------------- /.github/workflows/add-release-asset.yml: -------------------------------------------------------------------------------- 1 | name: Add release assets 2 | 3 | on: 4 | release: 5 | types: [published] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | add-script-to-release: 10 | runs-on: windows-latest 11 | 12 | permissions: 13 | contents: write 14 | 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Generate release files 20 | shell: pwsh 21 | run: | 22 | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force 23 | & ".\.github\workflows\doRelease.ps1" 24 | 25 | - name: Upload PowerShell script 26 | run: | 27 | gh release upload "$env:TAG" ./isoDebloater.ps1 --clobber 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | TAG: ${{ github.event.release.tag_name }} 31 | 32 | - name: Upload batch script 33 | run: | 34 | gh release upload "$env:TAG" ./isoDebloater.bat --clobber 35 | env: 36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 37 | TAG: ${{ github.event.release.tag_name }} 38 | -------------------------------------------------------------------------------- /download.ps1: -------------------------------------------------------------------------------- 1 | # $scriptUrl = "https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/main/isoDebloaterScript.ps1" 2 | $scriptUrl = "https://itsnileshhere.github.io/Windows-ISO-Debloater/isoDebloaterScript.ps1" 3 | $autounattendXmlUrl = "https://itsnileshhere.github.io/Windows-ISO-Debloater/autounattend.xml" 4 | 5 | $scriptDirectory = "$env:SystemDrive\scriptdir" 6 | 7 | if (-not (Test-Path -Path $scriptDirectory -PathType Container)) { 8 | New-Item -ItemType Directory -Path $scriptDirectory > $null 2>&1 9 | } 10 | 11 | $scriptPath = Join-Path -Path $scriptDirectory -ChildPath "isoDebloaterScript.ps1" 12 | $XmlPath = Join-Path -Path $scriptDirectory -ChildPath "autounattend.xml" 13 | 14 | Invoke-WebRequest -Uri $scriptUrl -OutFile $scriptPath 15 | Invoke-WebRequest -Uri $autounattendXmlUrl -OutFile $XmlPath 16 | 17 | function Test-WindowsTerminalInstalled { 18 | $terminalPath = "$env:LocalAppData\Microsoft\WindowsApps\wt.exe" 19 | return (Test-Path -Path $terminalPath) 20 | } 21 | 22 | if (Test-WindowsTerminalInstalled) { 23 | Start-Process -FilePath "$env:LocalAppData\Microsoft\WindowsApps\wt.exe" -ArgumentList "powershell -NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs 24 | } else { 25 | Start-Process -FilePath "PowerShell" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs 26 | } 27 | Start-Sleep -Milliseconds 200 28 | Exit 29 | -------------------------------------------------------------------------------- /.github/workflows/doRelease.ps1: -------------------------------------------------------------------------------- 1 | # Helper script to generate release files 2 | 3 | try { 4 | # Generate isoDebloater.ps1 5 | $isoDebloaterPs1 = @' 6 | param( 7 | [switch]$noPrompt, 8 | [string]$isoPath = "", 9 | [string]$winEdition = "", 10 | [string]$outputISO = "", 11 | [ValidateSet("yes", "no")]$useDISM = "", 12 | [ValidateSet("yes", "no")]$AppxRemove = "", 13 | [ValidateSet("yes", "no")]$CapabilitiesRemove = "", 14 | [ValidateSet("yes", "no")]$OnedriveRemove = "", 15 | [ValidateSet("yes", "no")]$EDGERemove = "", 16 | [ValidateSet("yes", "no")]$AIRemove = "", 17 | [ValidateSet("yes", "no")]$TPMBypass = "", 18 | [ValidateSet("yes", "no")]$UserFoldersEnable = "", 19 | [ValidateSet("yes", "no")]$DriverIntegrate = "", 20 | [ValidateSet("yes", "no")]$ESDConvert = "", 21 | [ValidateSet("yes", "no")]$useOscdimg = "" 22 | ) 23 | 24 | $scriptUrl = "https://itsnileshhere.github.io/Windows-ISO-Debloater/isoDebloaterScript.ps1" 25 | $autounattendXmlUrl = "https://itsnileshhere.github.io/Windows-ISO-Debloater/autounattend.xml" 26 | 27 | $scriptDirectory = "$env:SystemDrive\scriptdir" 28 | 29 | if (-not (Test-Path -Path $scriptDirectory -PathType Container)) { 30 | New-Item -ItemType Directory -Path $scriptDirectory > $null 2>&1 31 | } 32 | 33 | $scriptPath = Join-Path -Path $scriptDirectory -ChildPath "isoDebloaterScript.ps1" 34 | $XmlPath = Join-Path -Path $scriptDirectory -ChildPath "autounattend.xml" 35 | 36 | Invoke-WebRequest -Uri $scriptUrl -OutFile $scriptPath 37 | Invoke-WebRequest -Uri $autounattendXmlUrl -OutFile $XmlPath 38 | 39 | # Resolve relative paths 40 | if ($isoPath -and -not [System.IO.Path]::IsPathRooted($isoPath)) { 41 | $resolvedPath = Join-Path -Path (Get-Location).Path -ChildPath $isoPath 42 | if (Test-Path $resolvedPath) { 43 | $isoPath = (Get-Item $resolvedPath).FullName 44 | } else { 45 | $isoPath = [System.IO.Path]::GetFullPath($resolvedPath) 46 | } 47 | } 48 | 49 | if ($outputISO -and -not [System.IO.Path]::IsPathRooted($outputISO)) { 50 | $resolvedPath = Join-Path -Path (Get-Location).Path -ChildPath $outputISO 51 | $outputISO = [System.IO.Path]::GetFullPath($resolvedPath) 52 | } 53 | 54 | $params = @() 55 | $PSBoundParameters.GetEnumerator() | ForEach-Object { 56 | if ($_.Value -is [switch] -and $_.Value) { $params += "-$($_.Key)" } 57 | elseif ($_.Value -is [string] -and $_.Value) { 58 | # Use resolved paths 59 | if ($_.Key -eq 'isoPath' -and $isoPath) { $params += "-$($_.Key)", "`"$isoPath`"" } 60 | elseif ($_.Key -eq 'outputISO' -and $outputISO) { $params += "-$($_.Key)", "`"$outputISO`"" } 61 | else { $params += "-$($_.Key)", "`"$($_.Value)`"" } 62 | } 63 | } 64 | 65 | $paramString = if ($params.Count -gt 0) { " $($params -join ' ')" } else { "" } 66 | $argumentList = "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"$paramString" 67 | 68 | if (Test-Path "$env:LocalAppData\Microsoft\WindowsApps\wt.exe") { 69 | Start-Process -FilePath "$env:LocalAppData\Microsoft\WindowsApps\wt.exe" -ArgumentList "powershell $argumentList" -Verb RunAs 70 | } else { 71 | Start-Process -FilePath "PowerShell" -ArgumentList $argumentList -Verb RunAs 72 | } 73 | Start-Sleep -Milliseconds 200 74 | Exit 75 | '@ 76 | 77 | # Generate isoDebloater.bat 78 | $isoDebloaterBat = @' 79 | @(set "0=%~f0"^)#) & powershell -nop -c iex([io.file]::ReadAllText($env:0)) & exit /b 80 | # $scriptUrl = "https://raw.githubusercontent.com/itsNileshHere/Windows-ISO-Debloater/main/isoDebloaterScript.ps1" 81 | $scriptUrl = "https://itsnileshhere.github.io/Windows-ISO-Debloater/isoDebloaterScript.ps1" 82 | $autounattendXmlUrl = "https://itsnileshhere.github.io/Windows-ISO-Debloater/autounattend.xml" 83 | 84 | $scriptDirectory = "$env:SystemDrive\scriptdir" 85 | 86 | if (-not (Test-Path -Path $scriptDirectory -PathType Container)) { 87 | New-Item -ItemType Directory -Path $scriptDirectory > $null 2>&1 88 | } 89 | 90 | $scriptPath = Join-Path -Path $scriptDirectory -ChildPath "isoDebloaterScript.ps1" 91 | $XmlPath = Join-Path -Path $scriptDirectory -ChildPath "autounattend.xml" 92 | 93 | Invoke-WebRequest -Uri $scriptUrl -OutFile $scriptPath 94 | Invoke-WebRequest -Uri $autounattendXmlUrl -OutFile $XmlPath 95 | 96 | function Test-WindowsTerminalInstalled { 97 | $terminalPath = "$env:LocalAppData\Microsoft\WindowsApps\wt.exe" 98 | return (Test-Path -Path $terminalPath) 99 | } 100 | 101 | if (Test-WindowsTerminalInstalled) { 102 | Start-Process -FilePath "$env:LocalAppData\Microsoft\WindowsApps\wt.exe" -ArgumentList "powershell -NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs 103 | } else { 104 | Start-Process -FilePath "PowerShell" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs 105 | } 106 | Start-Sleep -Milliseconds 200 107 | Exit 108 | '@ 109 | 110 | # Write files to disk 111 | Set-Content -Path "isoDebloater.ps1" -Value $isoDebloaterPs1 112 | Set-Content -Path "isoDebloater.bat" -Value $isoDebloaterBat -NoNewline 113 | } 114 | catch { 115 | Write-Error "Error generating release files: $_" 116 | exit 1 117 | } -------------------------------------------------------------------------------- /autounattend.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | false 8 | 9 | true 10 | 11 | true 12 | 13 | false 14 | 15 | false 16 | 17 | Home 18 | 19 | false 20 | 21 | 22 | 23 | 24 | 25 | 26 | OnError 27 | 28 | 29 | 30 | 31 | Always 32 | 33 | false 34 | 35 | false 36 | true 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 1 50 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebar" /v "NoOpenWith" /t REG_SZ /d "" /f 1>nul 2>nul 51 | 52 | 53 | 2 54 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebar" /v "(Default)" /t REG_SZ /d "URL:ms-gamebar" /f 1>nul 2>nul 55 | 56 | 57 | 3 58 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebar" /v "URL Protocol" /t REG_SZ /d "" /f 1>nul 2>nul 59 | 60 | 61 | 4 62 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebar\shell\open\command" /ve /t REG_SZ /d "%SystemRoot%\System32\systray.exe" /f 1>nul 2>nul 63 | 64 | 65 | 5 66 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebarservices" /v "NoOpenWith" /t REG_SZ /d "" /f 1>nul 2>nul 67 | 68 | 69 | 6 70 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebarservices" /v "(Default)" /t REG_SZ /d "URL:ms-gamebarservices" /f 1>nul 2>nul 71 | 72 | 73 | 7 74 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebarservices" /v "URL Protocol" /t REG_SZ /d "" /f 1>nul 2>nul 75 | 76 | 77 | 8 78 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamebarservices\shell\open\command" /ve /t REG_SZ /d "%SystemRoot%\System32\systray.exe" /f 1>nul 2>nul 79 | 80 | 81 | 9 82 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamingoverlay" /v "NoOpenWith" /t REG_SZ /d "" /f 1>nul 2>nul 83 | 84 | 85 | 10 86 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamingoverlay" /v "(Default)" /t REG_SZ /d "URL:ms-gamingoverlay" /f 1>nul 2>nul 87 | 88 | 89 | 11 90 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamingoverlay" /v "URL Protocol" /t REG_SZ /d "" /f 1>nul 2>nul 91 | 92 | 93 | 12 94 | cmd.exe /c reg add "HKLM\SOFTWARE\Classes\ms-gamingoverlay\shell\open\command" /ve /t REG_SZ /d "%SystemRoot%\System32\systray.exe" /f 1>nul 2>nul 95 | 96 | 97 | 13 98 | cmd.exe /c reg add "HKLM\SOFTWARE\Microsoft\WindowsRuntime\Server\Windows.Gaming.GameBar.Internal.PresenceWriterServer" /v "ExePath" /t REG_SZ /d "%SystemRoot%\System32\systray.exe" /f 1>nul 2>nul 99 | 100 | 101 | 14 102 | cmd.exe /c reg add "HKLM\SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Gaming.GameBar.PresenceServer.Internal.PresenceWriter" /v ActivationType /t REG_DWORD /d 0 /f 1>nul 2>nul 103 | 104 | 105 | 15 106 | cmd.exe /c reg add "HKLM\SYSTEM\CurrentControlSet\Services\xbgm" /v "Start" /t REG_DWORD /d 4 /f 1>nul 2>nul 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows-ISO-Debloater 2 | 3 | ![Stars](https://img.shields.io/github/stars/itsNileshHere/Windows-ISO-Debloater?style=for-the-badge) 4 | [![Version](https://img.shields.io/github/v/release/itsNileshHere/Windows-ISO-Debloater?color=%230567ff&label=Latest%20Release&style=for-the-badge)](https://github.com/itsNileshHere/Windows-ISO-Debloater/releases/latest) 5 | [![Total Downloads](https://img.shields.io/github/downloads/itsNileshHere/Windows-ISO-Debloater/total?label=Total%20Downloads&style=for-the-badge)](https://github.com/itsNileshHere/Windows-ISO-Debloater/releases/latest) 6 | 7 | ## 📋 Overview 8 | 9 | An easy-to-use and customizable PowerShell script designed to optimize and debloat Windows ISO by removing unnecessary apps & components. Helps to create lightweight, clean ISOs for streamlined installations. Ideal for improved system performance and full control over Windows installation customization. 10 | 11 | ### Key Benefits: 12 | - **Performance Boost**: Creates lightweight Windows installations 13 | - **Clean Start**: Removes pre-installed bloatware before installation 14 | - **Customizable**: Provides full control over what gets removed from the ISO 15 | - **Privacy-Focused**: Removes components that may collect telemetry data 16 | - **Smaller ISO Size**: Reduces the overall size of installation media 17 | 18 | ## 🧪 Tested Versions 19 | 20 | The script has been thoroughly tested with: 21 | 22 | - **Windows 10**: Version 22H2 (Build 19045.3757) 23 | - **Windows 11**: Version 24H2 (Build 26100.1742) 24 | 25 | ⚠️ **Note**: The script should work with other Windows 10/11 versions as well. 26 | 27 | ## 🚀 Quick Installation 28 | 29 | ### Option 1: PowerShell Command (Recommended) 30 | 31 | Launch PowerShell as **Administrator** and execute: 32 | 33 | ```powershell 34 | irm "https://itsnileshhere.github.io/Windows-ISO-Debloater/download.ps1" | iex 35 | ``` 36 | 37 | ### Option 2: Manual Download and Execution 38 | 39 | Download the latest `isoDebloater.ps1` from [here](https://github.com/itsNileshHere/Windows-ISO-Debloater/releases/latest) 40 | 41 | #### Command Line Arguments 42 | 43 | ```powershell 44 | # SYNTAX 45 | .\isoDebloaterScript.ps1 [OPTIONS] 46 | 47 | # REQUIRED PARAMETERS FOR AUTOMATED MODE 48 | -noPrompt # Run without prompts (requires -isoPath, -winEdition, -outputISO) 49 | -isoPath "path\to\iso" # Path to Windows ISO file 50 | -winEdition "Name" # Name of Windows image to process (e.g., "Windows 11 Pro") 51 | -outputISO "Name" # Output ISO filename (without extension) 52 | 53 | # CUSTOMIZATION PARAMETERS (All accept "yes" or "no") [Optional] 54 | -useDISM "yes" # Use DISM.exe instead of PS cmdlets [Default: yes] 55 | -AppxRemove "yes" # Remove Microsoft Store apps [Default: yes] 56 | -CapabilitiesRemove "yes" # Remove optional Windows features [Default: yes] 57 | -OnedriveRemove "yes" # Remove OneDrive completely [Default: yes] 58 | -EDGERemove "yes" # Remove Microsoft Edge browser [Default: yes] 59 | -AIRemove "yes" # Remove AI Components [Default: yes] 60 | -TPMBypass "no" # Bypass TPM & hardware checks [Default: no] 61 | -UserFoldersEnable "yes" # Enable user folders in Explorer [Default: yes] 62 | -DriverIntegrate "no" # Integrate drivers from the Drivers folder [Default: no] 63 | -ESDConvert "no" # Compress ISO using ESD compression [Default: no] 64 | -useOscdimg "yes" # Use oscdimg.exe for ISO creation [Default: yes] 65 | 66 | # EXAMPLES 67 | # Basic usage with interactive prompts: 68 | .\isoDebloaterScript.ps1 69 | 70 | # Fully automated with no prompts: 71 | .\isoDebloaterScript.ps1 -noPrompt -isoPath "C:\path\to\windows.iso" -winEdition "Windows 11 Pro" -outputISO "Win11Debloat.iso" 72 | 73 | # Customize specific options: 74 | .\isoDebloaterScript.ps1 -isoPath "C:\path\to\windows.iso" -EDGERemove no -TPMBypass yes 75 | 76 | # Create minimal Windows installation: 77 | .\isoDebloaterScript.ps1 -AppxRemove yes -CapabilitiesRemove yes -OnedriveRemove yes -EDGERemove yes -AIRemove yes -ESDConvert yes 78 | 79 | # Integrate Intel RAID/VMD drivers: 80 | .\isoDebloaterScript.ps1 -isoPath "C:\path\to\windows.iso" -DriverIntegrate yes 81 | ``` 82 | 83 | ## 📝 Step-by-Step Usage Guide 84 | 85 | 1. After launching the script, a prompt will appear to select a Windows ISO file. 86 | 2. The script will mount the ISO and analyze its contents. 87 | 3. Options to customize which components to remove will be presented. 88 | 4. The script will process the ISO according to the selections. 89 | 5. A debloated ISO will be generated in the **same directory as the script**. 90 | 91 | ## 🛠️ Advanced Customization 92 | 93 | ### Packages & Features 94 | 95 | Components to be removed can be customized by editing the script: 96 | 97 | - **AppX Packages**: Modify the `$appxPatternsToRemove` array to include/exclude Microsoft Store apps 98 | - **Windows Capabilities**: Edit the `$capabilitiesToRemove` array to manage optional Windows features 99 | - **Windows Packages**: Adjust the `$windowsPackagesToRemove` array to control core Windows components 100 | 101 | ### Tweaks 102 | 103 | The script includes optimization tweaks to: 104 | - Improve system performance 105 | - Enhance privacy settings 106 | - Disable telemetry and data collection 107 | - Remove unnecessary UI elements 108 | - Remove AI components completely 109 | 110 | ## ⚙️ Technical Details 111 | 112 | ### ISO Generation Tool 113 | 114 | The script utilizes `oscdimg.exe`, a Microsoft tool for creating bootable ISO images. During execution, the script automatically downloads `oscdimg.exe` directly from Microsoft's servers and uses it to generate the modified ISO. 115 | 116 | For those who prefer to use their own copy of oscdimg.exe: 117 | 118 | 1. Download the "Windows ADK" from [Microsoft's official site](https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install) 119 | 2. During installation, select only the "Deployment Tools" component 120 | 3. Navigate to: `C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg` 121 | 4. Check if `oscdimg.exe` is installed properly 122 | 123 | ### ISO Generation Methods 124 | 125 | The script supports two methods for creating the final ISO file: 126 | 127 | #### 1. Oscdimg Method (Default) 128 | 129 | By default, the script uses `oscdimg.exe`, to create bootable ISO images 130 | - Downloads automatically if not present 131 | - Creates highly compatible ISO files 132 | - Recommended for most users 133 | 134 | To use this method (default): 135 | ```powershell 136 | .\isoDebloaterScript.ps1 -useOscdimg yes 137 | ``` 138 | 139 | #### 2. IMAPI2FS Method (Alternative) 140 | 141 | An alternative ISO generation method using the [IMAPI2FS interface](https://learn.microsoft.com/en-us/windows/win32/api/_imapi/) 142 | - Uses native Windows COM objects without external dependencies 143 | - Creates bootable ISOs directly through Windows COM interfaces 144 | - May work in environments where oscdimg has issues 145 | 146 | To use this method: 147 | ```powershell 148 | .\isoDebloaterScript.ps1 -useOscdimg no 149 | ``` 150 | 151 | ⚠️ **Note**: The IMAPI2FS method is still considered experimental and may not work in all environments. 152 | 153 | ## 📊 What Gets Removed? 154 | 155 | The script can remove various components based on preferences, including: 156 | 157 | - **Pre-installed Bloats**: Candy Crush, Disney+, Spotify, TikTok, etc. 158 | - **Microsoft Apps**: OneDrive, Skype, Teams, Office installers, Edge (optional) 159 | - **System Components**: Windows Media Player, Windows Fax and Scan, etc. 160 | - **Features**: Telemetry services, unnecessary language packs, etc. 161 | 162 | ## ⭐ Support 163 | 164 | If you find this project helpful, consider giving it a ⭐ on GitHub! 165 | 166 | ## 🌟 Credits 167 | 168 | - [tiny11builder](https://github.com/ntdevlabs/tiny11builder) for inspiration and approach 169 | - [Winaero](https://winaero.com/) for registry optimization techniques 170 | - Microsoft for Windows ADK tools 171 | 172 | ## ⚠️ Disclaimer 173 | 174 | This script modifies critical system files within the Windows ISO. While extensively tested, it's provided "as is" without warranties. The author is not liable for any damages that might occur from its use. 175 | 176 | - **Use at own risk** 177 | - **Always back up important data** before installing a modified Windows version 178 | 179 | ## 📜 License 180 | 181 | This project is licensed under the [GPL-3.0 License](https://github.com/itsNileshHere/Windows-ISO-Debloater/blob/main/LICENSE). 182 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /isoDebloaterScript.ps1: -------------------------------------------------------------------------------- 1 | # Windows ISO Debloater 2 | # Author: itsNileshHere 3 | # Date: 2023-11-21 4 | # Description: A simple PSscript to modify windows iso file. For more info check README.md 5 | 6 | param( 7 | [switch]$noPrompt, 8 | [string]$isoPath = "", 9 | [string]$winEdition = "", 10 | [string]$outputISO = "", 11 | [ValidateSet("yes", "no")]$useDISM = "", 12 | [ValidateSet("yes", "no")]$AppxRemove = "", 13 | [ValidateSet("yes", "no")]$CapabilitiesRemove = "", 14 | [ValidateSet("yes", "no")]$OnedriveRemove = "", 15 | [ValidateSet("yes", "no")]$EDGERemove = "", 16 | [ValidateSet("yes", "no")]$AIRemove = "", 17 | [ValidateSet("yes", "no")]$TPMBypass = "", 18 | [ValidateSet("yes", "no")]$UserFoldersEnable = "", 19 | [ValidateSet("yes", "no")]$DriverIntegrate = "", 20 | [ValidateSet("yes", "no")]$ESDConvert = "", 21 | [ValidateSet("yes", "no")]$useOscdimg = "" 22 | ) 23 | 24 | # If -noPrompt is used, ensure required parameters are provided 25 | if ($noPrompt) { 26 | $missing = @("isoPath","winEdition","outputISO") | Where-Object { [string]::IsNullOrWhiteSpace((Get-Variable $_).Value) } 27 | if ($missing) { Write-Error "When using -noPrompt, these parameters are required: $($missing -join ', ')"; Exit 1 } 28 | } 29 | 30 | # Disable Pause if -noprompt is used 31 | if ($noPrompt) { function Pause { } } 32 | 33 | # Administrator Privileges 34 | if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { 35 | Write-Host "This script must be run as Administrator. Re-launching with elevated privileges..." -ForegroundColor Yellow 36 | 37 | # Resolve relative paths before relaunching 38 | if ($isoPath -and -not [System.IO.Path]::IsPathRooted($isoPath)) { 39 | $isoPath = Join-Path -Path $PSScriptRoot -ChildPath $isoPath | Resolve-Path -ErrorAction SilentlyContinue 40 | if (-not $isoPath) { 41 | $isoPath = Join-Path -Path (Get-Location).Path -ChildPath $PSBoundParameters['isoPath'] 42 | if (Test-Path $isoPath) { 43 | $isoPath = (Get-Item $isoPath).FullName 44 | } 45 | } 46 | } 47 | if ($outputISO -and -not [System.IO.Path]::IsPathRooted($outputISO)) { 48 | $outputISO = Join-Path -Path (Get-Location).Path -ChildPath $outputISO 49 | $outputISO = [System.IO.Path]::GetFullPath($outputISO) 50 | } 51 | 52 | $params = @() 53 | $PSBoundParameters.GetEnumerator() | ForEach-Object { 54 | if ($_.Value -is [switch] -and $_.Value) { $params += "-$($_.Key)" } 55 | elseif ($_.Value -is [string] -and $_.Value) { 56 | # Use resolved paths for isoPath and outputISO 57 | if ($_.Key -eq 'isoPath' -and $isoPath) { $params += "-$($_.Key)", "`"$isoPath`"" } 58 | elseif ($_.Key -eq 'outputISO' -and $outputISO) { $params += "-$($_.Key)", "`"$outputISO`"" } 59 | else { $params += "-$($_.Key)", "`"$($_.Value)`"" } 60 | } 61 | } 62 | $argss = "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`" $($params -join ' ')" 63 | if (Get-Command wt -ErrorAction SilentlyContinue) { Start-Process wt "PowerShell $argss" -Verb RunAs } 64 | else { Start-Process PowerShell $argss -Verb RunAs } 65 | Exit 66 | } 67 | Clear-Host 68 | $asciiArt = @" 69 | _ ___ __ _________ ____ ____ __ __ __ 70 | | | / (_)___ ____/ /___ _ _______ / _/ ___// __ \ / __ \___ / /_ / /___ ____ _/ /____ _____ 71 | | | /| / / / __ \/ __ / __ \ | /| / / ___/ / / \__ \/ / / / / / / / _ \/ __ \/ / __ \/ __ `/ __/ _ \/ ___/ 72 | | |/ |/ / / / / / /_/ / /_/ / |/ |/ (__ ) _/ / ___/ / /_/ / / /_/ / __/ /_/ / / /_/ / /_/ / /_/ __/ / 73 | |__/|__/_/_/ /_/\__,_/\____/|__/|__/____/ /___//____/\____/ /_____/\___/_.___/_/\____/\__,_/\__/\___/_/ 74 | -By itsNileshHere 75 | "@ 76 | 77 | Write-Host $asciiArt -ForegroundColor Cyan 78 | Start-Sleep -Milliseconds 1000 79 | Write-Host "Starting Windows ISO Debloater Script..." -ForegroundColor Green 80 | Start-Sleep -Milliseconds 800 81 | Write-Host "`n*Important Notes: " -ForegroundColor Yellow 82 | Write-Host " 1. Some prompts will appear during the process." 83 | Write-Host " 2. Administrative privileges are required to run this script." 84 | Write-Host " 3. Review the script beforehand to understand its actions." 85 | Write-Host " 4. To whitelist a package, open the script and comment out the corresponding Packagename." 86 | Write-Host " 5. Select the ISO to proceed." 87 | Start-Sleep -Milliseconds 800 88 | 89 | $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' 90 | $PSDefaultParameterValues['*:Encoding'] = 'utf8' 91 | $scriptDirectory = "$PSScriptRoot" 92 | $logFilePath = Join-Path -Path $scriptDirectory -ChildPath 'script_log.txt' # Log File Path 93 | $transcript = "$env:TEMP\transcript_$(Get-Random).txt" # Start Transcript 94 | Start-Transcript $transcript -Append -ErrorAction SilentlyContinue 2>&1 | Out-Null 95 | 96 | # Get system information 97 | $osInfo = Get-WmiObject -Class Win32_OperatingSystem 98 | $logEntry = @" 99 | $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - Script started 100 | - Launched As: $((Get-CimInstance Win32_Process -Filter "ProcessId = $PID").CommandLine) 101 | - Windows Version: $($osInfo.Caption) $($osInfo.Version) (Build $($osInfo.BuildNumber)) 102 | - System Architecture: $($osInfo.OSArchitecture) 103 | - Install Date: $([Management.ManagementDateTimeConverter]::ToDateTime($osInfo.InstallDate).ToString()) 104 | - System Language: $((Get-Culture).DisplayName) 105 | - Default Language: $((Get-UICulture).DisplayName) 106 | - Windows Directory: $($env:windir)`n 107 | "@ 108 | 109 | # Initialize log file 110 | $logEntry | Out-File -FilePath $logFilePath -Append 111 | 112 | # Function to write logs 113 | function Write-Log { 114 | [CmdletBinding()] 115 | param ([Parameter(ValueFromPipeline=$true)][object]$InputObj, [string]$msg, [switch]$Raw, [string]$Sep = " || ") 116 | process { 117 | $content = if ($msg) { $msg } elseif ($null -ne $InputObj) { if ($InputObj -is [string]) { $InputObj } else { $InputObj | Out-String } } else { return } 118 | if (-not $Raw -and ($content = $content.Trim())) { 119 | $lines = @($content -split '\n' | Where-Object { $_.Trim() }) 120 | $cut = $lines | Where-Object { $_ -match '^\s*\+\s*(CategoryInfo|FullyQualifiedErrorId)\s*:' } | Select-Object -First 1 121 | if ($cut) { $lines = $lines[0..($lines.IndexOf($cut) - 1)] } 122 | if ($lines.Count -gt 1) { 123 | $processedLines = foreach ($line in $lines) { 124 | $trimmed = $line.Trim() 125 | if ($trimmed -match '^At\s+(.+)') { "At $($matches[1])" } 126 | elseif ($trimmed -match '^\s*\+\s*~+') { continue } # Skip underline line 127 | elseif ($trimmed -match '^\s*\+\s*(.+)') { "+ " + ($matches[1] -replace '\s{2,}', ' ') } 128 | elseif ($trimmed -match '^\s*\+?\s*(\w+\w+)\s*:\s*(.+)') { "$($matches[1]): $($matches[2])" } 129 | elseif ($trimmed -notmatch '^-{4,}' -and $trimmed) { $trimmed -replace '\s{2,}', ' ' } 130 | } 131 | $content = $processedLines -join $Sep 132 | } else { $content = $content -replace '\s{2,}', ' ' } 133 | } 134 | if ($content) { Add-Content -Path "$logFilePath" -Value "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - $content" } 135 | } 136 | } 137 | 138 | # Function to invoke DISM commands if powershell fails 139 | function Invoke-DismFailsafe { 140 | param([scriptblock]$PS, [scriptblock]$Dism) 141 | if ($useDISM -ieq "yes") { 142 | & $Dism 2>&1 | Write-Log 143 | } else { 144 | try { & $PS 2>&1 | Write-Log } catch { & $Dism 2>&1 | Write-Log } 145 | } 146 | } 147 | 148 | # Confirmation Function 149 | function Get-Confirmation { 150 | param([string]$Question, [bool]$DefaultValue = $true, [string]$Description = "") 151 | $defaultText = if ($DefaultValue) { "Y" } else { "N" } 152 | $optionsText = if ($DefaultValue) { "Y/n" } else { "y/N" } 153 | do { 154 | Write-Host "$Question" -ForegroundColor Cyan -NoNewline 155 | if ($Description) { Write-Host " - $Description" -ForegroundColor DarkGray -NoNewline } 156 | Write-Host " ($optionsText): " -ForegroundColor White -NoNewline 157 | $answer = Read-Host 158 | if ([string]::IsNullOrWhiteSpace($answer)) { 159 | Write-Host "Using default: $defaultText" -ForegroundColor Yellow 160 | return $DefaultValue 161 | } 162 | $answer = $answer.ToUpper() 163 | if ($answer -eq 'Y') { return $true } 164 | if ($answer -eq 'N') { return $false } 165 | Write-Warning "Invalid input. Enter 'Y' for Yes, 'N' for No, or Enter for default ($defaultText)." 166 | } while ($true) 167 | } 168 | 169 | # Parameter Value Validation Function 170 | function Get-ParameterValue { 171 | param( [string]$ParameterValue, [bool]$DefaultValue, [string]$Question, [string]$Description ) 172 | # If noPrompt is enabled, use default 173 | if ($noPrompt) { 174 | if ($ParameterValue -ne "") { return $ParameterValue -eq "yes" } 175 | else { return $DefaultValue } 176 | } 177 | # If noPrompt is null but param was provided, use the provided value 178 | if ($ParameterValue -ne "") { return $ParameterValue -eq "yes" } 179 | # If neither noPrompt nor param was provided, prompt the user 180 | return Get-Confirmation -Question $Question -DefaultValue $DefaultValue -Description $Description 181 | } 182 | 183 | # Cleanup Function 184 | function Remove-TempFiles { 185 | Remove-Item -Path $destinationPath -Recurse -Force 2>&1 | Write-Log 186 | Remove-Item -Path $installMountDir -Recurse -Force 2>&1 | Write-Log 187 | Remove-Item -Path "$env:SystemDrive\WIDTemp" -Recurse -Force 2>&1 | Write-Log 188 | Stop-Transcript 2>&1 | Write-Log 189 | $content = Get-Content $transcript | Where-Object { $_ -notmatch "^(Windows PowerShell transcript|Start time:|Username:|RunAs User:|Configuration|Host Application:|Process ID:|PS[A-Z]|BuildVersion:|CLRVersion:|WSManStackVersion:|SerializationVersion:|Transcript started|PS C:\\|^\*{10,}|End time:)" -and $_.Trim() } 190 | Add-Content $logFilePath -Value ("`n" + "="*50 + "`nTerminal Snapshot - $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" + "`n" + "="*50 + "`n" + ($content -join "`n")) 191 | Remove-Item $transcript -Force 2>&1 | Write-Log 192 | } 193 | 194 | # Set Ownership Permissions 195 | function Set-Ownership { 196 | param([string]$Path, [string[]]$Registry) 197 | if ($Path) { 198 | try { 199 | $FullPath = [System.IO.Path]::GetFullPath($Path) 200 | if (-not (Test-Path -Path $FullPath)) { return $true } 201 | $IsFolder = (Get-Item $FullPath).PSIsContainer 202 | $Acl = Get-Acl $FullPath 203 | $Acl.SetOwner([System.Security.Principal.NTAccount]"Administrators") 204 | $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name 205 | $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($CurrentUser, "FullControl", $(if ($IsFolder) {"ContainerInherit,ObjectInherit"} else {"None"}), "None", "Allow") 206 | $Acl.SetAccessRule($AccessRule) 207 | Set-Acl -Path $FullPath -AclObject $Acl 208 | if ($IsFolder) { Get-ChildItem -Path $FullPath -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object { 209 | try { $ChildAcl = Get-Acl $_.FullName 210 | $ChildAcl.SetOwner([System.Security.Principal.NTAccount]"Administrators") 211 | $ChildAcl.SetAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule($CurrentUser, "FullControl", "Allow"))) 212 | Set-Acl -Path $_.FullName -AclObject $ChildAcl } 213 | catch {} 214 | }} 215 | Write-Log -msg "Set ownership for: $FullPath" 216 | return $true 217 | } catch { Write-Log -msg "Failed to own path: $Path - $($_.Exception.Message)"; return $false } 218 | } 219 | if ($Registry) { 220 | try { 221 | $sid = (New-Object System.Security.Principal.NTAccount("BUILTIN\Administrators")).Translate([System.Security.Principal.SecurityIdentifier]) 222 | $rule = New-Object System.Security.AccessControl.RegistryAccessRule("Administrators", "FullControl", "ContainerInherit", "None", "Allow") 223 | foreach ($keyPath in $Registry) { 224 | try { 225 | $key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($keyPath, [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree, [System.Security.AccessControl.RegistryRights]::TakeOwnership) 226 | if ($key) { $acl = $key.GetAccessControl() 227 | $acl.SetOwner($sid) 228 | $key.SetAccessControl($acl) 229 | $key.Close() 230 | $key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($keyPath, [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree, [System.Security.AccessControl.RegistryRights]::ChangePermissions) 231 | if ($key) { $acl = $key.GetAccessControl() 232 | $acl.SetAccessRule($rule) 233 | $key.SetAccessControl($acl) 234 | $key.Close() 235 | Write-Log -msg "Set ownership for registry: $keyPath" 236 | } 237 | } else { Write-Log -msg "Unable to open reg-key: $keyPath" } 238 | } catch {} 239 | } 240 | return $true 241 | } catch { Write-Log -msg "Failed to own reg-key: $($_.Exception.Message)"; return $false } 242 | } 243 | return $false 244 | } 245 | 246 | # Force Remove Function 247 | function Set-OwnAndRemove { 248 | param([Parameter(Mandatory=$true)][string]$Path) 249 | try { 250 | $FullPath = [System.IO.Path]::GetFullPath($Path) 251 | if (-not (Test-Path -Path $FullPath)) { return $true } 252 | try { 253 | $ownershipResult = Set-Ownership -Path $Path 254 | if (-not $ownershipResult) { throw "ACL method failed" } 255 | Remove-Item -Path $FullPath -Force -Recurse -ErrorAction Stop 256 | Write-Log -msg "Removed with ACL: $FullPath" 257 | return $true 258 | } catch { 259 | Write-Log -msg "ACL method failed for: $FullPath" 260 | try { 261 | $IsFolder = (Get-Item $FullPath -ErrorAction Stop).PSIsContainer 262 | $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name 263 | if($IsFolder) { takeown /F "$FullPath" /R /D Y 2>&1 | Write-Log } 264 | else { takeown /F "$FullPath" /A 2>&1 | Write-Log } 265 | foreach ($Perm in @("*S-1-5-32-544:F", "System:F", "Administrators:F", "$CurrentUser`:F")) { 266 | try { 267 | if($IsFolder) { icacls "$FullPath" /grant:R "$Perm" /T /C 2>&1 | Write-Log } 268 | else { icacls "$FullPath" /grant:R "$Perm" 2>&1 | Write-Log } 269 | if ($LASTEXITCODE -eq 0) { break } 270 | } catch { continue } 271 | } 272 | Remove-Item -Path $FullPath -Force -Recurse -ErrorAction Stop 273 | Write-Log -msg "Removed with icacls: $FullPath" 274 | return $true 275 | } catch { Write-Log -msg "Failed to remove: $FullPath - $($_.Exception.Message)"; return $false } 276 | } 277 | } catch { Write-Log -msg "Error processing path: $Path - $($_.Exception.Message)"; return $false } 278 | } 279 | 280 | # Function to check internet connection 281 | function Test-InternetConnection { 282 | param ( 283 | [int]$maxAttempts = 3, 284 | [int]$retryDelay = 5, 285 | [string]$hostname = "1.1.1.1", # Cloudflare DNS 286 | [int]$port = 53, 287 | [int]$timeout = 5000 288 | ) 289 | for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) { 290 | try { 291 | $client = [Net.Sockets.TcpClient]::new() 292 | if ($client.ConnectAsync($hostname, $port).Wait($timeout)) { 293 | $client.Close(); return $true 294 | } 295 | $client.Close() 296 | } catch {} 297 | Write-Host "Internet connection not available, Trying in $retryDelay seconds..." 298 | Start-Sleep -Seconds $retryDelay 299 | } 300 | Write-Host "`nInternet connection not available after $maxAttempts attempts." -ForegroundColor Red 301 | Write-Host "A working internet connection is required to download oscdimg.exe." 302 | Write-Host "Check your connection and try again." 303 | 304 | while ($true) { 305 | $internetChoice = Read-Host -Prompt "`nPress 't' to try again or 'q' to quit" 306 | switch ($internetChoice.ToLower()) { 307 | 't' { return Test-InternetConnection @PSBoundParameters } 308 | 'q' { 309 | Remove-TempFiles 310 | Exit 311 | } 312 | default { Write-Host "Invalid input. Enter 't' or 'q'." } 313 | } 314 | } 315 | } 316 | 317 | # Image Info Function 318 | function Get-WimDetails { 319 | param ( [Parameter(Mandatory = $true)][string]$MountPath ) 320 | try { 321 | $out = dism /Image:$MountPath /Get-Intl /English | Out-String 322 | Write-Log -msg "DISM Output for Get-WimDetails:`n$out" 323 | $buildMatch = [regex]::Match($out, "Image Version: \d+\.\d+\.(\d+)\.\d+") 324 | $langMatch = [regex]::Match($out, "(?i)Default\s+system\s+UI\s+language\s*:\s*([a-z]{2}-[A-Z]{2})") 325 | [PSCustomObject]@{ 326 | BuildNumber = if ($buildMatch.Success) { $buildMatch.Groups[1].Value } else { $null } 327 | Language = if ($langMatch.Success) { $langMatch.Groups[1].Value } else { $null } 328 | } 329 | } 330 | catch { 331 | Write-Host "Failed to get WIM info: $($_.Exception.Message)" -ForegroundColor Red 332 | return $null 333 | } 334 | } 335 | 336 | # Get Image Index Function 337 | function Get-ImageIndex { 338 | param ( [Parameter(Mandatory = $true)][string]$ImagePath ) 339 | try { 340 | $out = & dism.exe /get-wiminfo /wimfile:$ImagePath /english 2>$null 341 | Write-Log -msg "DISM Output for Get-ImageIndex:`n$out" 342 | if ($LASTEXITCODE -ne 0) { throw "DISM failed to read image file: $ImagePath" } 343 | $images = @() 344 | $indexPattern = "Index\s*:\s*(\d+)" 345 | $namePattern = "Name\s*:\s*(.+)" 346 | for ($i = 0; $i -lt $out.Count; $i++) { 347 | if ($out[$i] -match $indexPattern) { 348 | $index = $matches[1] 349 | for ($j = $i + 1; $j -lt [Math]::Min($i + 5, $out.Count); $j++) { 350 | if ($out[$j] -match $namePattern) { 351 | $name = $matches[1].Trim() 352 | $images += [PSCustomObject]@{ 353 | Index = [int]$index 354 | ImageName = $name 355 | } 356 | break 357 | } 358 | } 359 | } 360 | } 361 | return $images 362 | } 363 | catch { 364 | Write-Log -msg "Failed to get image information: $($_.Exception.Message)" 365 | return $null 366 | } 367 | } 368 | 369 | # Oscdimg Path 370 | $OscdimgPath = "$env:SystemDrive\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg" 371 | $Oscdimg = Join-Path -Path $OscdimgPath -ChildPath 'oscdimg.exe' 372 | 373 | # Autounattend.xml Path 374 | $autounattendXmlPath = Join-Path -Path $scriptDirectory -ChildPath "Autounattend.xml" 375 | 376 | # Download Autounattend.xml if not exists 377 | if (-not (Test-Path $autounattendXmlPath)) { 378 | $ProgressPreference = 'SilentlyContinue' 379 | try { Invoke-WebRequest "https://itsnileshhere.github.io/Windows-ISO-Debloater/autounattend.xml" -OutFile $autounattendXmlPath -UseBasicParsing } 380 | catch { Write-Log -msg "Warning: Unable to download Autounattend.xml" } 381 | finally { $ProgressPreference = 'Continue' } 382 | } 383 | 384 | # Mount ISO Dialog 385 | function Select-ISOFile { 386 | Add-Type -AssemblyName System.Windows.Forms 387 | $dialog = New-Object System.Windows.Forms.OpenFileDialog 388 | $dialog.InitialDirectory = [Environment]::GetFolderPath("Desktop") 389 | $dialog.Filter = "ISO files (*.iso)|*.iso" 390 | $dialog.Title = "Select Windows ISO File" 391 | 392 | if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) { 393 | return $dialog.FileName 394 | } else { 395 | return $null 396 | } 397 | } 398 | 399 | if ($isoPath) {$isoFilePath = $isoPath} # If ISO path is provided as parameter 400 | else {$isoFilePath = Select-ISOFile} # Prompt user to select ISO file 401 | if ($null -eq $isoFilePath) { 402 | Write-Host "No file selected. Exiting Script" -ForegroundColor Red 403 | Write-Log -msg "No file selected" 404 | Pause 405 | Exit 406 | } 407 | 408 | Write-Host "`nSelected ISO file: " -NoNewline -ForegroundColor Cyan; Write-Host "$isoFilePath" 409 | Write-Log -msg "ISO Path: $isoFilePath" 410 | 411 | # Mounting ISO File 412 | $mountResult = Mount-DiskImage -ImagePath "$isoFilePath" -PassThru 413 | if ($mountResult) { 414 | $sourceDriveLetter = ($mountResult | Get-Volume).DriveLetter 415 | if ($sourceDriveLetter) { 416 | Write-Log -msg "Mounted ISO file to drive: $sourceDriveLetter`:" 417 | } 418 | } 419 | else { 420 | Write-Host "Failed to mount the ISO file." -ForegroundColor Red 421 | Write-Log -msg "Failed to mount the ISO file." 422 | Pause 423 | Exit 424 | } 425 | 426 | $sourceDrive = "${sourceDriveLetter}:\" # Source Drive of ISO 427 | $destinationPath = "$env:SystemDrive\WIDTemp\winlite" # Destination Path 428 | $installMountDir = "$env:SystemDrive\WIDTemp\mountdir\installWIM" # Mount Directory 429 | 430 | # Copy Files 431 | Write-Host "`nCopying files from " -NoNewline; Write-Host "`"$sourceDrive`"" -ForegroundColor Yellow -NoNewline; Write-Host " to " -NoNewline; Write-Host "`"$destinationPath`"" -ForegroundColor Yellow; Write-Log -msg "Copying files from $sourceDrive to $destinationPath" 432 | try { 433 | if (-not (Test-Path $destinationPath)) { New-Item -ItemType Directory -Path $destinationPath -Force -EA Stop | Out-Null } 434 | Write-Log -msg "Starting file copy operation..." 435 | 436 | # Using Robocopy to copy files 437 | $robocopyOutput = & robocopy.exe $sourceDrive $destinationPath /E /COPY:DAT /R:3 /W:5 /MT:8 /NFL /NDL /NP 2>&1 438 | $robocopyExitCode = $LASTEXITCODE 439 | $robocopyOutput | Write-Log 440 | if ($robocopyExitCode -le 7) { 441 | Write-Host "Copy completed successfully." -ForegroundColor Green 442 | Write-Log -msg "Copy completed (Exit: $robocopyExitCode)" 443 | Write-Log -msg "Removing read-only attributes..." 444 | Get-ChildItem -Path $destinationPath -Recurse | ForEach-Object { $_.Attributes = $_.Attributes -band (-bnot [System.IO.FileAttributes]::ReadOnly) } | Out-Null 445 | } 446 | else { throw "Robocopy failed: $robocopyExitCode" } 447 | } catch { Write-Log -msg "Copy failed: $($_.Exception.Message)"; throw } 448 | 449 | try { if (Test-Path $isoFilePath) { Dismount-DiskImage -ImagePath $isoFilePath -EA Stop | Out-Null} } 450 | catch { Write-Log -msg "Dismount failed: $($_.Exception.Message)" } 451 | 452 | # Check files availability 453 | $installWimPath = Join-Path $destinationPath "sources\install.wim" 454 | $installEsdPath = Join-Path $destinationPath "sources\install.esd" 455 | New-Item -ItemType Directory -Path $installMountDir 2>&1 | Write-Log 456 | 457 | # Handling install.wim and install.esd 458 | if (-not (Test-Path $installWimPath)) { 459 | Write-Host "`ninstall.wim not found. Searching for install.esd..." 460 | if (Test-Path $installEsdPath) { 461 | Write-Host "`ninstall.esd found at " -NoNewline -ForegroundColor Cyan; Write-Host "$installEsdPath" 462 | Write-Log -msg "install.esd found. Converting..." 463 | Write-Host "Details for image: " -NoNewline -ForegroundColor Cyan; Write-Host "$installEsdPath" 464 | try { 465 | # Get image info from install.esd 466 | $esdInfo = Get-ImageIndex -ImagePath $installEsdPath 467 | if (-not $esdInfo) { 468 | Write-Host "Error: Could not retrieve image info from WIM file" -ForegroundColor Red 469 | Remove-TempFiles 470 | Pause 471 | Exit 472 | } 473 | # Print image details from install.esd 474 | foreach ($image in $esdInfo) { 475 | Write-Host "$($image.Index). $($image.ImageName)" 476 | } 477 | # If winEdition is specified, find the index; else prompt user 478 | if ($winEdition) { 479 | $matchedImage = $esdInfo | Where-Object { $_.ImageName -ieq $winEdition } 480 | if ($matchedImage) { $sourceIndex = $matchedImage.Index } 481 | else { $sourceIndex = 1 } 482 | } 483 | else { $sourceIndex = Read-Host -Prompt "`nEnter the index to convert and mount" } 484 | # Check if the index is valid, print selected "ImageIndex - ImageName" 485 | $selectedImage = $esdInfo | Where-Object { $_.Index -eq [int]$sourceIndex } 486 | if ($selectedImage) { 487 | Write-Host "`nMounting image: " -NoNewline -ForegroundColor Cyan; Write-Host "$sourceIndex. $($selectedImage.ImageName)" 488 | Write-Log -msg "Converting and Mounting image: $sourceIndex. $($selectedImage.ImageName)" 489 | } 490 | 491 | # Convert ESD to WIM 492 | Invoke-DismFailsafe {Export-WindowsImage -SourceImagePath $installEsdPath -SourceIndex $sourceIndex -DestinationImagePath $installWimPath -CompressionType Maximum -CheckIntegrity} {dism /Export-Image /SourceImageFile:$installEsdPath /SourceIndex:$sourceIndex /DestinationImageFile:$installWimPath /Compress:max /CheckIntegrity} 493 | # Remove the ESD file after conversion 494 | Remove-Item $installEsdPath -Force 495 | # Mount the converted WIM with SourceIndex 1 496 | Invoke-DismFailsafe {Mount-WindowsImage -ImagePath $installWimPath -Index 1 -Path $installMountDir} {dism /mount-image /imagefile:$installWimPath /index:1 /mountdir:$installMountDir} 497 | $sourceIndex = 1 # After conversion, the new WIM will have only one image 498 | } 499 | catch { 500 | Write-Host "Failed to convert or mount the ESD image: $_" -ForegroundColor Red 501 | Write-Log -msg "Failed to mount image: $_" 502 | Pause 503 | Exit 504 | } 505 | } 506 | else { 507 | Write-Host "Neither install.wim nor install.esd found. Make sure to mount the correct ISO" -ForegroundColor Red 508 | Write-Log -msg "Neither install.wim nor install.esd found" 509 | Pause 510 | Exit 511 | } 512 | } 513 | else { 514 | Write-Host "`nDetails for image: " -NoNewline -ForegroundColor Cyan; Write-Host "$installWimPath" 515 | Write-Log -msg "Getting image info" 516 | try { 517 | # Get image info from install.wim 518 | $wimInfo = Get-ImageIndex -ImagePath $installWimPath 519 | if (-not $wimInfo) { 520 | Write-Host "Error: Could not retrieve image info from WIM file" -ForegroundColor Red 521 | Remove-TempFiles 522 | Pause 523 | Exit 524 | } 525 | # Print image details from install.wim 526 | foreach ($image in $wimInfo) { 527 | Write-Host "$($image.Index). $($image.ImageName)" 528 | } 529 | # If winEdition is specified, find the index; else prompt user 530 | if ($winEdition) { 531 | $matchedImage = $wimInfo | Where-Object { $_.ImageName -ieq $winEdition } 532 | if ($matchedImage) { $sourceIndex = $matchedImage.Index } 533 | else { $sourceIndex = 1 } 534 | } 535 | else { $sourceIndex = Read-Host -Prompt "`nEnter the index to mount" } 536 | # Check if the index is valid, print selected "ImageIndex - ImageName" 537 | $selectedImage = $wimInfo | Where-Object { $_.Index -eq [int]$sourceIndex } 538 | if ($selectedImage) { 539 | Write-Host "`nMounting image: " -NoNewline -ForegroundColor Cyan; Write-Host "$sourceIndex. $($selectedImage.ImageName)" 540 | Write-Log -msg "Mounting image: $sourceIndex. $($selectedImage.ImageName)" 541 | } 542 | 543 | Invoke-DismFailsafe {Mount-WindowsImage -ImagePath $installWimPath -Index $sourceIndex -Path $installMountDir} {dism /mount-image /imagefile:$installWimPath /index:$sourceIndex /mountdir:$installMountDir} 544 | } 545 | catch { 546 | Write-Host "Failed to mount the image: $_" -ForegroundColor Red 547 | Write-Log -msg "Failed to mount image: $_" 548 | Pause 549 | Exit 550 | } 551 | } 552 | 553 | # Check if wim-mount was successful 554 | if (-not (Test-Path "$installMountDir\Windows")) { 555 | Write-Host "Error while mounting image. Try again." -ForegroundColor Red 556 | Write-Log -msg "Mounted image not found. Exiting" 557 | Remove-TempFiles 558 | Pause 559 | Exit 560 | } 561 | 562 | # Resolve Image Info 563 | $WimDetails = Get-WimDetails -MountPath $installMountDir 564 | if (-not $WimDetails -or -not $WimDetails.BuildNumber -or -not $WimDetails.Language) { 565 | Write-Host "Error: Could not retrieve WIM information from mounted path" -ForegroundColor Red 566 | Remove-TempFiles 567 | Pause 568 | Exit 569 | } 570 | $langCode = $WimDetails.Language; Write-Log -msg "Detected Language: $langCode" 571 | $buildNumber = $WimDetails.BuildNumber; Write-Log -msg "Detected Build Number: $buildNumber" 572 | 573 | Write-Host 574 | $DoAppxRemove = Get-ParameterValue -ParameterValue $AppxRemove -DefaultValue $true -Question "Remove unnecessary packages?" -Description "Recommended: Removes bloatware apps" 575 | $DoCapabilitiesRemove = Get-ParameterValue -ParameterValue $CapabilitiesRemove -DefaultValue $true -Question "Remove unnecessary features?" -Description "Recommended: Removes optional Windows features" 576 | $DoOnedriveRemove = Get-ParameterValue -ParameterValue $OnedriveRemove -DefaultValue $true -Question "Remove OneDrive?" -Description "Optional: Completely removes OneDrive" 577 | $DoEDGERemove = Get-ParameterValue -ParameterValue $EDGERemove -DefaultValue $true -Question "Remove Microsoft Edge?" -Description "Optional: Removes Edge browser" 578 | $DoAIRemove = Get-ParameterValue -ParameterValue $AIRemove -DefaultValue $true -Question "Remove AI Components?" -Description "Optional: Removes everything related to AI" 579 | $DoTPMBypass = Get-ParameterValue -ParameterValue $TPMBypass -DefaultValue $false -Question "Bypass TPM check?" -Description "Only if needed for older hardware" 580 | $DoUserFoldersEnable = Get-ParameterValue -ParameterValue $UserFoldersEnable -DefaultValue $true -Question "Enable user folders?" -Description "Recommended: Enables Desktop, Documents, etc." 581 | $DoDriverIntegrate = Get-ParameterValue -ParameterValue $DriverIntegrate -DefaultValue $false -Question "Integrate Intel RST/VMD drivers?" -Description "Optional: Helps with Intel VMD storage controllers" 582 | $DoESDConvert = Get-ParameterValue -ParameterValue $ESDConvert -DefaultValue $false -Question "Compress the ISO?" -Description "Recommended but slow: Reduces ISO file size" 583 | $DoUseOscdimg = Get-ParameterValue -ParameterValue $useOscdimg -DefaultValue $true -Question "Use Oscdimg for ISO creation?" -Description "Recommended: Oscdimg is more reliable" 584 | 585 | # Comment out the package don't wanna remove 586 | $appxPatternsToRemove = @( 587 | "Microsoft.Microsoft3DViewer*", # 3DViewer 588 | "Microsoft.WindowsAlarms*", # Alarms 589 | "Microsoft.BingNews*", # Bing News 590 | "Microsoft.BingWeather*", # Bing Weather 591 | "Clipchamp.Clipchamp*", # Clipchamp 592 | "Microsoft.549981C3F5F10*", # Cortana 593 | "Microsoft.Windows.DevHome*", # DevHome 594 | "MicrosoftCorporationII.MicrosoftFamily*", # Family 595 | "Microsoft.WindowsFeedbackHub*", # FeedbackHub 596 | "Microsoft.GetHelp*", # GetHelp 597 | "Microsoft.Getstarted*", # GetStarted 598 | "Microsoft.WindowsCommunicationsapps*", # Mail 599 | "Microsoft.WindowsMaps*", # Maps 600 | "Microsoft.MixedReality.Portal*", # MixedReality 601 | "Microsoft.ZuneMusic*", # Music 602 | "Microsoft.MicrosoftOfficeHub*", # OfficeHub 603 | "Microsoft.Office.OneNote*", # OneNote 604 | "Microsoft.OutlookForWindows*", # Outlook 605 | "Microsoft.MSPaint*", # Paint3D(Windows10) 606 | "Microsoft.People*", # People 607 | "Microsoft.YourPhone*", # Phone 608 | "Microsoft.PowerAutomateDesktop*", # PowerAutomate 609 | "MicrosoftCorporationII.QuickAssist*", # QuickAssist 610 | "Microsoft.SkypeApp*", # Skype 611 | "Microsoft.MicrosoftSolitaireCollection*", # SolitaireCollection 612 | # "Microsoft.WindowsSoundRecorder*", # SoundRecorder 613 | "MicrosoftTeams*", # Teams_old 614 | "MSTeams*", # Teams 615 | "Microsoft.Windows.Teams*", # Teams 616 | "Microsoft.Todos*", # Todos 617 | "Microsoft.ZuneVideo*", # Video 618 | "Microsoft.Wallet*", # Wallet 619 | "Microsoft.GamingApp*", # Xbox 620 | "Microsoft.XboxApp*", # Xbox(Win10) 621 | "Microsoft.XboxGameOverlay*", # XboxGameOverlay 622 | "Microsoft.XboxGamingOverlay*", # XboxGamingOverlay 623 | "Microsoft.XboxSpeechToTextOverlay*", # XboxSpeechToTextOverlay 624 | "Microsoft.Xbox.TCUI*", # XboxTCUI 625 | # "Microsoft.SecHealthUI*", # Windows Security 626 | "MicrosoftWindows.CrossDevice*", # CrossDevice 627 | "Microsoft.Windows.PeopleExperienceHost*", # PeopleExperienceHost 628 | "Windows.CBSPreview*", # CBS Preview 629 | "Microsoft.BingSearch*" # Bing Search 630 | ) 631 | 632 | $capabilitiesToRemove = @( 633 | "Browser.InternetExplorer*", 634 | "Internet-Explorer*", 635 | "App.StepsRecorder*", 636 | "Language.Handwriting~~~$langCode*", 637 | "Language.OCR~~~$langCode*", 638 | "Language.Speech~~~$langCode*", 639 | "Language.TextToSpeech~~~$langCode*", 640 | "Microsoft.Windows.WordPad*", 641 | "MathRecognizer*", 642 | "Media.WindowsMediaPlayer*", 643 | "Microsoft.Windows.PowerShell.ISE*" 644 | ) 645 | 646 | $windowsPackagesToRemove = @( 647 | "Microsoft-Windows-InternetExplorer-Optional-Package*", 648 | "Microsoft-Windows-LanguageFeatures-Handwriting-$langCode-Package*", 649 | "Microsoft-Windows-LanguageFeatures-OCR-$langCode-Package*", 650 | "Microsoft-Windows-LanguageFeatures-Speech-$langCode-Package*", 651 | "Microsoft-Windows-LanguageFeatures-TextToSpeech-$langCode-Package*", 652 | "Microsoft-Windows-Wallpaper-Content-Extended-FoD-Package*", 653 | "Microsoft-Windows-WordPad-FoD-Package*", 654 | "Microsoft-Windows-MediaPlayer-Package*", 655 | "Microsoft-Windows-TabletPCMath-Package*", 656 | "Microsoft-Windows-StepsRecorder-Package*" 657 | ) 658 | 659 | function Remove-Packages { 660 | param( [string[]]$Patterns, [string]$SectionTitle, [string]$PackageType, [string]$MountPath, [int]$StartIndex = 1, [int]$TotalCount, [int]$StatusColumn ) 661 | 662 | # Package configurations 663 | $config = @{ 664 | 'AppX' = @{ 665 | GetCommand = { Get-ProvisionedAppxPackage -Path $MountPath } 666 | FilterProperty = 'PackageName' 667 | RemoveCommand = { param($item) Remove-ProvisionedAppxPackage -Path $MountPath -PackageName $item.PackageName } 668 | LogPrefix = 'AppX package' 669 | } 670 | 'Capability' = @{ 671 | GetCommand = { Get-WindowsCapability -Path $MountPath } 672 | FilterProperty = 'Name' 673 | RemoveCommand = { param($item) Remove-WindowsCapability -Path $MountPath -Name $item.Name } 674 | LogPrefix = 'capability' 675 | } 676 | 'WindowsPackage' = @{ 677 | GetCommand = { Get-WindowsPackage -Path $MountPath } 678 | FilterProperty = 'PackageName' 679 | RemoveCommand = { param($item) Remove-WindowsPackage -Path $MountPath -PackageName $item.PackageName } 680 | LogPrefix = 'Windows package' 681 | } 682 | } 683 | if ($SectionTitle) { Write-Host "`n$SectionTitle" -ForegroundColor Cyan; Write-Log -msg $SectionTitle } 684 | 685 | # Validate Package Type 686 | $cfg = $config[$PackageType] 687 | $filterProp = $cfg.FilterProperty 688 | 689 | for ($i = 0; $i -lt $Patterns.Count; $i++) { 690 | $pattern = $Patterns[$i] 691 | $displayName = $pattern.TrimEnd('*') 692 | $counter = "[{0}/{1}]" -f ($StartIndex + $i), $TotalCount 693 | $initialOutput = " $counter $displayName" 694 | 695 | Write-Host $initialOutput -NoNewline # Display initial output 696 | try { 697 | $items = & $cfg.GetCommand | Where-Object { $_.$filterProp -like $pattern } 698 | $itemsRemoved = 0 699 | foreach ($item in $items) { 700 | try { 701 | & $cfg.RemoveCommand $item 2>&1 | Write-Log 702 | $itemsRemoved++ 703 | } 704 | catch { 705 | $itemName = $item.$filterProp 706 | Write-Log -msg "Removing $($cfg.LogPrefix) $itemName failed: $_" 707 | } 708 | } 709 | 710 | # Show status 711 | $padding = $StatusColumn - $initialOutput.Length 712 | $spaces = ' ' * $padding 713 | if ($itemsRemoved -gt 0) { Write-Host "$spaces[REMOVED]" -ForegroundColor Green } 714 | else { Write-Host "$spaces[NOT FOUND]" -ForegroundColor Yellow } 715 | } 716 | catch { 717 | Write-Log -msg "Failed to remove $PackageType matching '$pattern': $_" 718 | $padding = $StatusColumn - $initialOutput.Length 719 | Write-Host "$(' ' * $padding)[ERROR]" -ForegroundColor Red 720 | } 721 | } 722 | } 723 | 724 | $allPatterns = $appxPatternsToRemove + $capabilitiesToRemove + $windowsPackagesToRemove 725 | $maxLength = ($allPatterns | ForEach-Object { $_.TrimEnd('*').Length } | Measure-Object -Maximum).Maximum 726 | $statusColumn = $maxLength + 18 727 | 728 | # Remove AppX Packages 729 | if ($DoAppxRemove) { 730 | Remove-Packages -Patterns $appxPatternsToRemove -SectionTitle "Removing provisioned Packages:" -PackageType "AppX" -MountPath $installMountDir -TotalCount $appxPatternsToRemove.Count -StatusColumn $statusColumn 731 | } else { 732 | Write-Log -msg "Skipped Package Removal" 733 | } 734 | 735 | # Remove Capabilities and Windows Packages 736 | if ($DoCapabilitiesRemove) { 737 | $capabilitiesAndPackagesTotal = $capabilitiesToRemove.Count + $windowsPackagesToRemove.Count 738 | Remove-Packages -Patterns $capabilitiesToRemove -SectionTitle "Removing Unnecessary Windows Features:" -PackageType "Capability" -MountPath $installMountDir -TotalCount $capabilitiesAndPackagesTotal -StatusColumn $statusColumn 739 | Remove-Packages -Patterns $windowsPackagesToRemove -SectionTitle "" -PackageType "WindowsPackage" -MountPath $installMountDir -StartIndex ($capabilitiesToRemove.Count + 1) -TotalCount $capabilitiesAndPackagesTotal -StatusColumn $statusColumn 740 | } else { 741 | Write-Log -msg "Skipped Features Removal" 742 | } 743 | 744 | # # Remove Recall (Have conflict with Explorer) 745 | # Write-Host "`nRemoving Recall..." 746 | # Write-Log -msg "Removing Recall" 747 | # dism /image:$installMountDir /Disable-Feature /FeatureName:'Recall' /Remove 2>&1 | Write-Log 748 | # Write-Host "Done" 749 | 750 | # # Remove OutlookPWA 751 | # Write-Host "`nRemoving Outlook..." -ForegroundColor Cyan 752 | # Write-Log -msg "Removing OutlookPWA" 753 | # Get-ChildItem "$installMountDir\Windows\WinSxS\amd64_microsoft-windows-outlookpwa*" -Directory | ForEach-Object { Set-OwnAndRemove -Path $_.FullName } 2>&1 | Write-Log 754 | # Write-Host "Done" -ForegroundColor Green 755 | 756 | # Setting Permissions 757 | function Enable-Privilege { 758 | param([ValidateSet('SeAssignPrimaryTokenPrivilege', 'SeAuditPrivilege', 'SeBackupPrivilege', 'SeChangeNotifyPrivilege', 'SeCreateGlobalPrivilege', 'SeCreatePagefilePrivilege', 'SeCreatePermanentPrivilege', 'SeCreateSymbolicLinkPrivilege', 'SeCreateTokenPrivilege', 'SeDebugPrivilege', 'SeEnableDelegationPrivilege', 'SeImpersonatePrivilege', 'SeIncreaseBasePriorityPrivilege', 'SeIncreaseQuotaPrivilege', 'SeIncreaseWorkingSetPrivilege', 'SeLoadDriverPrivilege', 'SeLockMemoryPrivilege', 'SeMachineAccountPrivilege', 'SeManageVolumePrivilege', 'SeProfileSingleProcessPrivilege', 'SeRelabelPrivilege', 'SeRemoteShutdownPrivilege', 'SeRestorePrivilege', 'SeSecurityPrivilege', 'SeShutdownPrivilege', 'SeSyncAgentPrivilege', 'SeSystemEnvironmentPrivilege', 'SeSystemProfilePrivilege', 'SeSystemtimePrivilege', 'SeTakeOwnershipPrivilege', 'SeTcbPrivilege', 'SeTimeZonePrivilege', 'SeTrustedCredManAccessPrivilege', 'SeUndockPrivilege', 'SeUnsolicitedInputPrivilege')]$Privilege, $ProcessId = $pid, [Switch]$Disable) 759 | $def = @' 760 | using System;using System.Runtime.InteropServices;public class AdjPriv{[DllImport("advapi32.dll",ExactSpelling=true,SetLastError=true)]internal static extern bool AdjustTokenPrivileges(IntPtr htok,bool disall,ref TokPriv1Luid newst,int len,IntPtr prev,IntPtr relen);[DllImport("advapi32.dll",ExactSpelling=true,SetLastError=true)]internal static extern bool OpenProcessToken(IntPtr h,int acc,ref IntPtr phtok);[DllImport("advapi32.dll",SetLastError=true)]internal static extern bool LookupPrivilegeValue(string host,string name,ref long pluid);[StructLayout(LayoutKind.Sequential,Pack=1)]internal struct TokPriv1Luid{public int Count;public long Luid;public int Attr;}public static bool EnablePrivilege(long processHandle,string privilege,bool disable){var tp=new TokPriv1Luid();tp.Count=1;tp.Attr=disable?0:2;IntPtr htok=IntPtr.Zero;if(!OpenProcessToken(new IntPtr(processHandle),0x28,ref htok))return false;if(!LookupPrivilegeValue(null,privilege,ref tp.Luid))return false;return AdjustTokenPrivileges(htok,false,ref tp,0,IntPtr.Zero,IntPtr.Zero);}} 761 | '@ 762 | (Add-Type $def -PassThru -EA SilentlyContinue)[0]::EnablePrivilege((Get-Process -id $ProcessId).Handle, $Privilege, $Disable) 763 | } 764 | Enable-Privilege SeTakeOwnershipPrivilege | Out-Null 765 | 766 | # Remove OneDrive 767 | if ($DoOnedriveRemove) { 768 | Write-Host ("`n[INFO] Removing OneDrive...") -ForegroundColor Cyan 769 | Write-Log -msg "Defining OneDrive Setup file paths" 770 | $oneDriveSetupPath1 = Join-Path -Path $installMountDir -ChildPath 'Windows\System32\OneDriveSetup.exe' 771 | $oneDriveSetupPath2 = Join-Path -Path $installMountDir -ChildPath 'Windows\SysWOW64\OneDriveSetup.exe' 772 | # $oneDriveSetupPath3 = (Join-Path -Path $installMountDir -ChildPath 'Windows\WinSxS\*microsoft-windows-onedrive-setup*\OneDriveSetup.exe' | Get-Item -ErrorAction SilentlyContinue).FullName 773 | # $oneDriveSetupPath4 = (Get-ChildItem "$installMountDir\Windows\WinSxS\amd64_microsoft-windows-onedrive-setup*" -Directory).FullName 774 | $oneDriveShortcut = Join-Path -Path $installMountDir -ChildPath 'Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk' 775 | 776 | Write-Log -msg "Removing OneDrive" 777 | Set-OwnAndRemove -Path $oneDriveSetupPath1 | Out-Null 778 | Set-OwnAndRemove -Path $oneDriveSetupPath2 | Out-Null 779 | # $oneDriveSetupPath3 | Where-Object { $_ } | ForEach-Object { Set-OwnAndRemove -Path $_ } 2>&1 | Write-Log 780 | # $oneDriveSetupPath4 | Where-Object { $_ } | ForEach-Object { Set-OwnAndRemove -Path $_ } 2>&1 | Write-Log 781 | Set-OwnAndRemove -Path $oneDriveShortcut | Out-Null 782 | 783 | Write-Host ("[OK] OneDrive Removed") -ForegroundColor Green 784 | Write-Log -msg "OneDrive removed successfully" 785 | } else { 786 | Write-Log -msg "OneDrive removal skipped" 787 | } 788 | 789 | # Remove EDGE 790 | if ($DoEDGERemove) { 791 | Write-Host ("`n[INFO] Removing EDGE...") -ForegroundColor Cyan 792 | Write-Log -msg "Removing EDGE" 793 | 794 | # Edge Patterns 795 | $EDGEpatterns = @( 796 | "Microsoft.MicrosoftEdge.Stable*", 797 | "Microsoft.MicrosoftEdgeDevToolsClient*", 798 | "Microsoft.Win32WebViewHost*", 799 | "MicrosoftWindows.Client.WebExperience*" 800 | ) 801 | 802 | # Remove Edge Packages 803 | foreach ($pattern in $EDGEpatterns) { 804 | $matchedPackages = Get-ProvisionedAppxPackage -Path $installMountDir | 805 | Where-Object { $_.PackageName -like $pattern } 806 | foreach ($package in $matchedPackages) { 807 | Invoke-DismFailsafe {Remove-ProvisionedAppxPackage -Path $installMountDir -PackageName $package.PackageName} {dism /image:$installMountDir /Remove-ProvisionedAppxPackage /PackageName:$($package.PackageName)} 808 | } 809 | } 810 | 811 | # Modifying reg keys 812 | try { 813 | reg load HKLM\zSOFTWARE "$installMountDir\Windows\System32\config\SOFTWARE" 2>&1 | Write-Log 814 | reg load HKLM\zSYSTEM "$installMountDir\Windows\System32\config\SYSTEM" 2>&1 | Write-Log 815 | reg load HKLM\zNTUSER "$installMountDir\Users\Default\ntuser.dat" 2>&1 | Write-Log 816 | reg load HKLM\zDEFAULT "$installMountDir\Windows\System32\config\default" 2>&1 | Write-Log 817 | 818 | # Registry operations 819 | reg delete "HKLM\zSOFTWARE\Microsoft\EdgeUpdate" /f 2>&1 | Write-Log 820 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f 2>&1 | Write-Log 821 | reg delete "HKLM\zDEFAULT\Software\Microsoft\EdgeUpdate" /f 2>&1 | Write-Log 822 | reg delete "HKLM\zNTUSER\Software\Microsoft\EdgeUpdate" /f 2>&1 | Write-Log 823 | reg delete "HKLM\zSOFTWARE\Microsoft\Active Setup\Installed Components\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" /f 2>&1 | Write-Log 824 | reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Edge" /f 2>&1 | Write-Log 825 | reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" /f 2>&1 | Write-Log 826 | reg delete "HKLM\zSYSTEM\CurrentControlSet\Services\edgeupdate" /f 2>&1 | Write-Log 827 | reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdate" /f 2>&1 | Write-Log 828 | reg delete "HKLM\zSYSTEM\CurrentControlSet\Services\edgeupdatem" /f 2>&1 | Write-Log 829 | reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdatem" /f 2>&1 | Write-Log 830 | reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f 2>&1 | Write-Log 831 | reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f 2>&1 | Write-Log 832 | reg add "HKLM\zSOFTWARE\Microsoft\MicrosoftEdge\Main" /v "AllowPrelaunch" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 833 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\MicrosoftEdge\Main" /v "AllowPrelaunch" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 834 | reg add "HKLM\zNTUSER\Software\Microsoft\MicrosoftEdge\Main" /v "AllowPrelaunch" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 835 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\MicrosoftEdge\Main" /v "AllowPrelaunch" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 836 | reg add "HKLM\zSOFTWARE\Microsoft\MicrosoftEdge\TabPreloader" /v "AllowTabPreloading" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 837 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader" /v "AllowTabPreloading" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 838 | reg add "HKLM\zNTUSER\Software\Microsoft\MicrosoftEdge\TabPreloader" /v "AllowTabPreloading" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 839 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\MicrosoftEdge\TabPreloader" /v "AllowTabPreloading" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 840 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\EdgeUpdate" /v "UpdateDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 841 | 842 | # Disable Edge updates and installation 843 | $registryKeys = @( 844 | "HKLM\zSOFTWARE\Microsoft\EdgeUpdate", 845 | "HKLM\zSOFTWARE\Policies\Microsoft\EdgeUpdate", 846 | "HKLM\zSOFTWARE\WOW6432Node\Microsoft\EdgeUpdate", 847 | "HKLM\zNTUSER\Software\Microsoft\EdgeUpdate", 848 | "HKLM\zNTUSER\Software\Policies\Microsoft\EdgeUpdate" 849 | ) 850 | foreach ($key in $registryKeys) { 851 | reg add "$key" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 852 | reg add "$key" /v "UpdaterExperimentationAndConfigurationServiceControl" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 853 | reg add "$key" /v "InstallDefault" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 854 | } 855 | } 856 | catch { 857 | Write-Log -msg "Error modifying registry: $_" 858 | } 859 | finally { 860 | # Always unload registry hives regardless of errors 861 | reg unload HKLM\zSOFTWARE 2>&1 | Write-Log 862 | reg unload HKLM\zSYSTEM 2>&1 | Write-Log 863 | reg unload HKLM\zNTUSER 2>&1 | Write-Log 864 | reg unload HKLM\zDEFAULT 2>&1 | Write-Log 865 | } 866 | 867 | # Remove EDGE files 868 | Remove-Item -Path "$installMountDir\Program Files\Microsoft\Edge" -Recurse -Force 2>&1 | Write-Log 869 | Remove-Item -Path "$installMountDir\Program Files\Microsoft\EdgeCore" -Recurse -Force 2>&1 | Write-Log 870 | Remove-Item -Path "$installMountDir\Program Files\Microsoft\EdgeUpdate" -Recurse -Force 2>&1 | Write-Log 871 | Remove-Item -Path "$installMountDir\Program Files\Microsoft\EdgeWebView" -Recurse -Force 2>&1 | Write-Log 872 | Remove-Item -Path "$installMountDir\Program Files (x86)\Microsoft\Edge" -Recurse -Force 2>&1 | Write-Log 873 | Remove-Item -Path "$installMountDir\Program Files (x86)\Microsoft\EdgeCore" -Recurse -Force 2>&1 | Write-Log 874 | Remove-Item -Path "$installMountDir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force 2>&1 | Write-Log 875 | Remove-Item -Path "$installMountDir\Program Files (x86)\Microsoft\EdgeWebView" -Recurse -Force 2>&1 | Write-Log 876 | Remove-Item -Path "$installMountDir\ProgramData\Microsoft\EdgeUpdate" -Recurse -Force 2>&1 | Write-Log 877 | Get-ChildItem "$installMountDir\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.MicrosoftEdge.Stable*" -Directory | ForEach-Object { Set-OwnAndRemove -Path $_.FullName } 2>&1 | Write-Log 878 | Get-ChildItem "$installMountDir\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.MicrosoftEdgeDevToolsClient*" -Directory | ForEach-Object { Set-OwnAndRemove -Path $_.FullName } 2>&1 | Write-Log 879 | # Get-ChildItem "$installMountDir\Windows\WinSxS\*microsoft-edge-webview*" -Directory | ForEach-Object { Set-OwnAndRemove -Path $_.FullName } 2>&1 | Write-Log 880 | Set-OwnAndRemove -Path (Join-Path -Path $installMountDir -ChildPath 'Windows\System32\Microsoft-Edge-WebView') | Out-Null 881 | Set-OwnAndRemove -Path (Join-Path -Path $installMountDir -ChildPath 'Windows\SystemApps\Microsoft.Win32WebViewHost*' | Get-Item -ErrorAction SilentlyContinue).FullName | Out-Null 882 | 883 | # Removing EDGE-Task 884 | Get-ChildItem -Path "$installMountDir\Windows\System32\Tasks\MicrosoftEdge*" | Where-Object { $_ } | ForEach-Object { Set-OwnAndRemove -Path $_ } 2>&1 | Write-Log 885 | 886 | # For Windows 10 (Legacy EDGE) 887 | if ($buildNumber -lt 22000) { 888 | Get-ChildItem -Path "$installMountDir\Windows\SystemApps\Microsoft.MicrosoftEdge*" | Where-Object { $_ } | ForEach-Object { Set-OwnAndRemove -Path $_ } 2>&1 | Write-Log 889 | } 890 | 891 | Write-Host ("[OK] EDGE has been removed") -ForegroundColor Green 892 | Write-Log -msg "Microsoft Edge removal completed" 893 | } else { 894 | Write-Log -msg "Edge removal cancelled" 895 | } 896 | 897 | # Remove AI components 898 | if ($buildNumber -ge 22000) { 899 | if ($DoAIRemove) { 900 | Write-Host ("`n[INFO] Removing AI components...") -ForegroundColor Cyan 901 | Write-Log -msg "Removing AI components" 902 | 903 | # Remove AI Packages 904 | $AIpatterns = @( 905 | "Microsoft.Windows.Copilot*", 906 | "Microsoft.Copilot*" 907 | ) 908 | foreach ($pattern in $AIpatterns) { 909 | $matchedPackages = Get-ProvisionedAppxPackage -Path $installMountDir | 910 | Where-Object { $_.PackageName -like $pattern } 911 | foreach ($package in $matchedPackages) { 912 | Invoke-DismFailsafe {Remove-ProvisionedAppxPackage -Path $installMountDir -PackageName $package.PackageName} {dism /image:$installMountDir /Remove-ProvisionedAppxPackage /PackageName:$($package.PackageName)} 913 | } 914 | } 915 | 916 | # Disable AI DLLs 917 | $dllfiles = @('System32', 'SysWOW64') | ForEach-Object { 918 | Join-Path $installMountDir "Windows\$_\Windows.AI.MachineLearning.dll" 919 | Join-Path $installMountDir "Windows\$_\Windows.AI.MachineLearning.Preview.dll" 920 | } 921 | $dllfiles += Join-Path $installMountDir "Windows\System32\SettingsHandlers_Copilot.dll" 922 | $dllfiles | Where-Object { Test-Path $_ } | ForEach-Object { 923 | Set-Ownership -Path $_ | Out-Null 924 | Rename-Item $_ ($_ + ".bak") -Force 2>&1 | Write-Log 925 | } 926 | 927 | # Modifying reg keys 928 | try { 929 | reg load HKLM\zSOFTWARE "$installMountDir\Windows\System32\config\SOFTWARE" 2>&1 | Write-Log 930 | reg load HKLM\zSYSTEM "$installMountDir\Windows\System32\config\SYSTEM" 2>&1 | Write-Log 931 | reg load HKLM\zNTUSER "$installMountDir\Users\Default\ntuser.dat" 2>&1 | Write-Log 932 | 933 | # Registry operations 934 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\Explorer" /v "DisableSearchBoxSuggestions" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 935 | # Disable AI in Notepad 936 | reg add "HKLM\zSOFTWARE\Policies\WindowsNotepad" /v "DisableAIFeatures" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 937 | # Disable AI in Paint 938 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Paint" /v "DisableCocreator" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 939 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Paint" /v "DisableImageCreator" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 940 | # Disable AI in other apps 941 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\AppPrivacy" /v "LetAppsAccessSystemAIModels" /t REG_DWORD /d "2" /f 2>&1 | Write-Log 942 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\AppPrivacy" /v "LetAppsAccessGenerativeAI" /t REG_DWORD /d "2" /f 2>&1 | Write-Log 943 | # Disable AI access 944 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\generativeAI" /v "Value" /t REG_SZ /d "Deny" /f 2>&1 | Write-Log 945 | # Disable AI in Edge 946 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Edge" /v "HubsSidebarEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 947 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Edge" /v "CopilotPageContext" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 948 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Edge" /v "CopilotCDPPageContext" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 949 | # Disable AI in Search 950 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsAI" /v "DisableClickToDo" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 951 | # Disable WSAIFabricSvc Service 952 | reg add "HKLM\zSYSTEM\CurrentControlSet\Services\WSAIFabricSvc" /v "Start" /t REG_DWORD /d "4" /f 2>&1 | Write-Log 953 | # Hide AI components from Settings 954 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "SettingsPageVisibility" /t REG_SZ /d "hide:aicomponents" /f 2>&1 | Write-Log 955 | # Disable AI from Explorer 956 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\WindowsCopilot" /v "AllowCopilotRuntime" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 957 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband\AuxilliaryPins" /v "CopilotPWAPin" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 958 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband\AuxilliaryPins" /v "RecallPin" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 959 | # Disable Copilot and Recall system-wide 960 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsCopilot" /v "TurnOffWindowsCopilot" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 961 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsAI" /v "DisableAIDataAnalysis" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 962 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsAI" /v "AllowRecallEnablement" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 963 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsAI" /v "TurnOffSavingSnapshots" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 964 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsAI" /v "DisableSettingsAgent" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 965 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\Shell\Copilot" /v "IsCopilotAvailable" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 966 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\Shell\Copilot" /v "CopilotDisabledReason" /t REG_SZ /d "FeatureIsDisabled" /f 2>&1 | Write-Log 967 | # Disable Copilot and Recall for New Users 968 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\Windows\WindowsCopilot" /v "TurnOffWindowsCopilot" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 969 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\Windows\WindowsAI" /v "DisableAIDataAnalysis" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 970 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\Windows\WindowsAI" /v "AllowRecallEnablement" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 971 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\Windows\WindowsAI" /v "TurnOffSavingSnapshots" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 972 | reg add "HKLM\zNTUSER\Software\Policies\Microsoft\Windows\WindowsAI" /v "DisableSettingsAgent" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 973 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\Shell\Copilot" /v "IsCopilotAvailable" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 974 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\Shell\Copilot" /v "CopilotDisabledReason" /t REG_SZ /d "FeatureIsDisabled" /f 2>&1 | Write-Log 975 | # Remove AI Tasks 976 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\WindowsAI" /f 2>&1 | Write-Log 977 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\WindowsAI" | Out-Null 978 | 979 | # Disable Recall on first logon 980 | if ($buildNumber -ge 22000) { 981 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v "DisableRecall" /t REG_SZ /d "dism.exe /online /disable-feature /FeatureName:recall" /f 2>&1 | Write-Log 982 | } 983 | } 984 | catch { 985 | Write-Log -msg "Error modifying registry: $_" 986 | } 987 | finally { 988 | # Always unload registry hives regardless of errors 989 | reg unload HKLM\zSOFTWARE 2>&1 | Write-Log 990 | reg unload HKLM\zSYSTEM 2>&1 | Write-Log 991 | reg unload HKLM\zNTUSER 2>&1 | Write-Log 992 | } 993 | Write-Host ("[OK] AI Components removed") -ForegroundColor Green 994 | Write-Log -msg "AI Components removal completed" 995 | } else { 996 | Write-Log -msg "AI Components removal skipped" 997 | } 998 | } 999 | 1000 | # Registry Tweaks 1001 | Write-Host ("`n[INFO] Loading Registry...") -ForegroundColor Cyan 1002 | Write-Log -msg "Loading registry" 1003 | reg load HKLM\zCOMPONENTS "$installMountDir\Windows\System32\config\COMPONENTS" 2>&1 | Write-Log 1004 | reg load HKLM\zDEFAULT "$installMountDir\Windows\System32\config\default" 2>&1 | Write-Log 1005 | reg load HKLM\zNTUSER "$installMountDir\Users\Default\ntuser.dat" 2>&1 | Write-Log 1006 | reg load HKLM\zSOFTWARE "$installMountDir\Windows\System32\config\SOFTWARE" 2>&1 | Write-Log 1007 | reg load HKLM\zSYSTEM "$installMountDir\Windows\System32\config\SYSTEM" 2>&1 | Write-Log 1008 | 1009 | # Setting Permissions 1010 | Set-Ownership -Registry @("zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications", "zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks", "zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows", "zSOFTWARE\Microsoft\WindowsRuntime\Server\Windows.Gaming.GameBar.Internal.PresenceWriterServer") | Out-Null 1011 | 1012 | Write-Host ("[OK] Registry loaded") -ForegroundColor Green 1013 | 1014 | # Modify registry settings 1015 | Write-Host ("`n[INFO] Performing Registry Tweaks...") -ForegroundColor Cyan 1016 | 1017 | # Disable Sponsored Apps 1018 | Write-Host -NoNewline (" Disabling Sponsored Apps".PadRight($statusColumn)) 1019 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "OemPreInstalledAppsEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1020 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1021 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1022 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1023 | reg add "HKLM\zSOFTWARE\Microsoft\PolicyManager\current\device\Start" /v "ConfigureStartPins" /t REG_SZ /d '{\"pinnedList\": [{}]}' /f 2>&1 | Write-Log 1024 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContentEnabled" /t REG_SZ /d "0" /f 2>&1 | Write-Log 1025 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContentEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1026 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-310093Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1027 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338388Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1028 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338389Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1029 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338393Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1030 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-353694Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1031 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-353696Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1032 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338387Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1033 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "ContentDeliveryAllowed" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1034 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEverEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1035 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SoftLandingEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1036 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SystemPaneSuggestionsEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1037 | reg delete "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions" /f 2>&1 | Write-Log 1038 | reg delete "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps" /f 2>&1 | Write-Log 1039 | Write-Host "[DONE]" -ForegroundColor Green 1040 | 1041 | # Disable Telemetry 1042 | Write-Host -NoNewline (" Disabling Telemetry".PadRight($statusColumn)) 1043 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1044 | reg add "HKLM\zNTUSER\Software\Microsoft\Personalization\Settings" /v "AcceptedPrivacyPolicy" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1045 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Privacy" /v "TailoredExperiencesWithDiagnosticDataEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1046 | reg add "HKLM\zNTUSER\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy" /v "HasAccepted" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1047 | reg add "HKLM\zNTUSER\Software\Microsoft\InputPersonalization" /v "RestrictImplicitInkCollection" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1048 | reg add "HKLM\zNTUSER\Software\Microsoft\InputPersonalization" /v "RestrictImplicitTextCollection" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1049 | reg add "HKLM\zNTUSER\Software\Microsoft\InputPersonalization\TrainedDataStore" /v "HarvestContacts" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1050 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v "Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1051 | reg add "HKLM\zSYSTEM\ControlSet001\Services\dmwappushservice" /v "Start" /t REG_DWORD /d "4" /f 2>&1 | Write-Log 1052 | Write-Host "[DONE]" -ForegroundColor Green 1053 | 1054 | # Disable Mouse Acceleration 1055 | Write-Host -NoNewline (" Disabling Mouse Acceleration".PadRight($statusColumn)) 1056 | reg add "HKLM\zNTUSER\Control Panel\Mouse" /v "MouseSpeed" /t REG_SZ /d "0" /f 2>&1 | Write-Log 1057 | reg add "HKLM\zNTUSER\Control Panel\Mouse" /v "MouseThreshold1" /t REG_SZ /d "0" /f 2>&1 | Write-Log 1058 | reg add "HKLM\zNTUSER\Control Panel\Mouse" /v "MouseThreshold2" /t REG_SZ /d "0" /f 2>&1 | Write-Log 1059 | Write-Host "[DONE]" -ForegroundColor Green 1060 | 1061 | # Disable Meet Now icon 1062 | Write-Host -NoNewline (" Disabling Meet".PadRight($statusColumn)) 1063 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "HideSCAMeetNow" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1064 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "AllowOnlineTips" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1065 | Write-Host "[DONE]" -ForegroundColor Green 1066 | 1067 | # Disable Ads and Stuffs 1068 | Write-Host -NoNewline (" Disabling Ads and Stuffs".PadRight($statusColumn)) 1069 | # Disable ad tailoring 1070 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v "Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1071 | # Disable cloud-based content 1072 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent" /v "DisableConsumerAccountStateContent" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1073 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent" /v "DisableCloudOptimizedContent" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1074 | # Disable Start Menu Suggestions 1075 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_IrisRecommendations" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1076 | # Disable News and Interest 1077 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Feeds" /v "EnableFeeds" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1078 | # Remove Spotlight icon from Desktop 1079 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{2cc5ca98-6485-489a-920e-b3e88a6ccce3}" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1080 | # Disable Cortana 1081 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "AllowCortana" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1082 | # Changes MenuShowDelay from 400 to 200 1083 | reg add "HKLM\zNTUSER\Control Panel\Desktop" /v "MenuShowDelay" /t REG_SZ /d "200" /f 2>&1 | Write-Log 1084 | # Disable everytime MRT download through Win Update 1085 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\MRT" /v "DontOfferThroughWUAU" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1086 | # Disable Teams Auto installation 1087 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Teams" /v "DisableInstallation" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1088 | # Disable Outlook 1089 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Mail" /v "PreventRun" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1090 | Write-Host "[DONE]" -ForegroundColor Green 1091 | 1092 | # Disable Bitlocker 1093 | Write-Host -NoNewline (" Disabling Bitlocker Encryption".PadRight($statusColumn)) 1094 | reg add "HKLM\zSYSTEM\ControlSet001\Control\BitLocker" /v "PreventDeviceEncryption" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1095 | Write-Host "[DONE]" -ForegroundColor Green 1096 | 1097 | # Disable OneDrive Stuffs 1098 | Write-Host -NoNewline (" Removing OneDrive Junks".PadRight($statusColumn)) 1099 | reg delete "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f 2>&1 | Write-Log 1100 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\OneDrive" /v "DisableLibrariesDefaultSaveToOneDrive" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1101 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\OneDrive" /v "DisableFileSyncNGSC" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1102 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\OneDrive" /v "KFMBlockOptIn" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1103 | Write-Host "[DONE]" -ForegroundColor Green 1104 | 1105 | # Disable GameDVR 1106 | Write-Host -NoNewline (" Disabling GameDVR and Components".PadRight($statusColumn)) 1107 | reg add "HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v "AppCaptureEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1108 | reg add "HKLM\zNTUSER\System\GameConfigStore" /v "GameDVR_Enabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1109 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\GameDVR" /v "AllowGameDVR" /t REG_DWORD /d 0 /f 2>&1 | Write-Log 1110 | reg add "HKLM\zSYSTEM\ControlSet001\Services\BcastDVRUserService" /v "Start" /t REG_DWORD /d 4 /f 2>&1 | Write-Log 1111 | reg add "HKLM\zSYSTEM\ControlSet001\Services\GameBarPresenceWriter" /v "Start" /t REG_DWORD /d 4 /f 2>&1 | Write-Log 1112 | Write-Host "[DONE]" -ForegroundColor Green 1113 | 1114 | # Remove Gamebar Popup 1115 | # Courtesy: https://pastebin.com/EAABLssA by aveyo 1116 | Write-Host -NoNewline (" Removing Gamebar Popup".PadRight($statusColumn)) 1117 | reg add "HKLM\zNTUSER\Software\Microsoft\GameBar" /v "AutoGameModeEnabled" /t REG_DWORD /d 0 /f 2>&1 | Write-Log 1118 | # Rest added as post install script. Somehow, implementing it directly on the image was causing corruption 1119 | Write-Host "[DONE]" -ForegroundColor Green 1120 | 1121 | # # Configure GameBarFTServer (NA) 1122 | # $packageKey = "HKLM\zSOFTWARE\Classes\PackagedCom\ClassIndex\{FD06603A-2BDF-4BB1-B7DF-5DC68F353601}" 1123 | # $app = (Get-Item "Registry::$packageKey").PSChildName 1124 | # reg add "HKLM\zSOFTWARE\Classes\PackagedCom\Package\$app\Server\0" /v "Executable" /t REG_SZ /d "systray.exe" /f 2>&1 | Write-Log 1125 | 1126 | # Enabling Local Account Creation 1127 | Write-Host -NoNewline (" Tweaking OOBE Settings".PadRight($statusColumn)) 1128 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\OOBE" /v "DisablePrivacyExperience" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1129 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\OOBE" /v "BypassNRO" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1130 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\OOBE" /v "BypassNROGatherOptions" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1131 | 1132 | # Check if Autounattend.xml exists before copying 1133 | if (Test-Path -Path $autounattendXmlPath) { 1134 | Write-Log -msg "Copying Autounattend.xml" 1135 | Copy-Item -Path $autounattendXmlPath -Destination $destinationPath -Force 1136 | } else { 1137 | Write-Warning "Autounattend.xml not found at $autounattendXmlPath" 1138 | Write-Log -msg "Warning: Autounattend.xml not found at $autounattendXmlPath" 1139 | } 1140 | Write-Host "[DONE]" -ForegroundColor Green 1141 | 1142 | # Prevents Dev Home Installation 1143 | Write-Host -NoNewline (" Disabling useless junks".PadRight($statusColumn)) 1144 | reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate" /f 2>&1 | Write-Log 1145 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\DevHomeUpdate" /v "workCompleted" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1146 | 1147 | # Prevents New Outlook for Windows Installation 1148 | reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate" /f 2>&1 | Write-Log 1149 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\OutlookUpdate" /v "workCompleted" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1150 | 1151 | # Prevents Chat Auto Installation 1152 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications" /v "ConfigureChatAutoInstall" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1153 | reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Chat" /v "ChatIcon" /t REG_DWORD /d "3" /f 2>&1 | Write-Log 1154 | Write-Host "[DONE]" -ForegroundColor Green 1155 | 1156 | # Disable Scheduled Tasks 1157 | Write-Host -NoNewline (" Disabling Scheduled Tasks".PadRight($statusColumn)) 1158 | $win24H2 = (Get-ItemProperty -Path 'Registry::HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name DisplayVersion).DisplayVersion -eq '24H2' 1159 | if ($win24H2) { 1160 | # Customer Experience Improvement Program 1161 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{780E487D-C62F-4B55-AF84-0E38116AFE07}" /f 2>&1 | Write-Log 1162 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{FD607F42-4541-418A-B812-05C32EBA8626}" /f 2>&1 | Write-Log 1163 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{E4FED5BC-D567-4044-9642-2EDADF7DE108}" /f 2>&1 | Write-Log 1164 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\Customer Experience Improvement Program" | Out-Null 1165 | # Program Data Updater 1166 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{E292525C-72F1-482C-8F35-C513FAA98DAE}" /f 2>&1 | Write-Log 1167 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null 1168 | # Application Compatibility Appraiser 1169 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{3047C197-66F1-4523-BA92-6C955FEF9E4E}" /f 2>&1 | Write-Log 1170 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{A0C71CB8-E8F0-498A-901D-4EDA09E07FF4}" /f 2>&1 | Write-Log 1171 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null 1172 | } 1173 | else { 1174 | # Customer Experience Improvement Program 1175 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{4738DE7A-BCC1-4E2D-B1B0-CADB044BFA81}" /f 2>&1 | Write-Log 1176 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{6FAC31FA-4A85-4E64-BFD5-2154FF4594B3}" /f 2>&1 | Write-Log 1177 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{FC931F16-B50A-472E-B061-B6F79A71EF59}" /f 2>&1 | Write-Log 1178 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Customer Experience Improvement Program" /f 2>&1 | Write-Log 1179 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\Customer Experience Improvement Program" | Out-Null 1180 | # Program Data Updater 1181 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{0671EB05-7D95-4153-A32B-1426B9FE61DB}" /f 2>&1 | Write-Log 1182 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null 1183 | # Application Compatibility Appraiser 1184 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{0600DD45-FAF2-4131-A006-0B17509B9F78}" /f 2>&1 | Write-Log 1185 | Set-OwnAndRemove -Path "$installMountDir\Windows\System32\Tasks\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null 1186 | } 1187 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Application Experience\PcaPatchDbTask" /f 2>&1 | Write-Log 1188 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Application Experience\MareBackup" /f 2>&1 | Write-Log 1189 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /f 2>&1 | Write-Log 1190 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Autochk\Proxy" /f 2>&1 | Write-Log 1191 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /f 2>&1 | Write-Log 1192 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" /f 2>&1 | Write-Log 1193 | Write-Host "[DONE]" -ForegroundColor Green 1194 | 1195 | # Disable TPM CHeck 1196 | if ($DoTPMBypass) { 1197 | Write-Host ("`n[INFO] Disabling TPM Check...") -ForegroundColor Cyan 1198 | Write-Host (" This may take some time") -ForegroundColor DarkGray 1199 | Write-Log -msg "Disabling TPM Check" 1200 | reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1201 | reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1202 | reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassStorageCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1203 | reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassCPUCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1204 | reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1205 | reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassDiskCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1206 | reg add "HKLM\zSYSTEM\Setup\MoSetup" /v "AllowUpgradesWithUnsupportedTPMOrCPU" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1207 | 1208 | # Disable Unsupported Hardware Watermark 1209 | reg add "HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV1" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1210 | reg add "HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV2" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1211 | reg add "HKLM\zNTUSER\Control Panel\UnsupportedHardwareNotificationCache" /v "SV1" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1212 | reg add "HKLM\zNTUSER\Control Panel\UnsupportedHardwareNotificationCache" /v "SV2" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1213 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "HideUnsupportedHardwareNotifications" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1214 | # Clear upgrade failure records 1215 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\CompatMarkers" /f 2>&1 | Write-Log 1216 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Shared" /f 2>&1 | Write-Log 1217 | reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\TargetVersionUpgradeExperienceIndicators" /f 2>&1 | Write-Log 1218 | # Simulate meeting requirements 1219 | reg add "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\HwReqChk" /v "HwReqChkVars" /t REG_MULTI_SZ /d "SQ_SecureBootCapable=TRUE\0SQ_SecureBootEnabled=TRUE\0SQ_TpmVersion=2\0SQ_RamMB=8192" /f 2>&1 | Write-Log 1220 | # Set Upgrade Eligibility 1221 | reg add "HKLM\zNTUSER\Software\Microsoft\PCHC" /v "UpgradeEligibility" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1222 | 1223 | # Remove appraiserres.dll and replace with blank file 1224 | $apprdllPath = Join-Path -Path $destinationPath -ChildPath "sources\appraiserres.dll" 1225 | Set-OwnAndRemove -Path "$apprdllPath" | Out-Null 1226 | New-Item -Path $apprdllPath -ItemType File -Force 2>&1 | Write-Log 1227 | try { 1228 | $ProgressPreference = 'SilentlyContinue' 1229 | $bootWimPath = Join-Path $destinationPath "sources\boot.wim" 1230 | $bootMountDir = "$env:SystemDrive\WIDTemp\mountdir\bootWIM" 1231 | New-Item -ItemType Directory -Path $bootMountDir 2>&1 | Write-Log 1232 | Invoke-DismFailsafe {Mount-WindowsImage -ImagePath $bootWimPath -Index 2 -Path $bootMountDir}{ {dism /mount-image /imagefile:$bootWimPath /index:2 /mountdir:$bootMountDir}} 1233 | 1234 | reg load HKLM\xDEFAULT "$bootMountDir\Windows\System32\config\default" 2>&1 | Write-Log 1235 | reg load HKLM\xNTUSER "$bootMountDir\Users\Default\ntuser.dat" 2>&1 | Write-Log 1236 | reg load HKLM\xSYSTEM "$bootMountDir\Windows\System32\config\SYSTEM" 2>&1 | Write-Log 1237 | reg load HKLM\xSOFTWARE "$bootMountDir\Windows\System32\config\SOFTWARE" 2>&1 | Write-Log 1238 | 1239 | reg add "HKLM\xSYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d 1 /f 2>&1 | Write-Log 1240 | reg add "HKLM\xSYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d 1 /f 2>&1 | Write-Log 1241 | reg add "HKLM\xSYSTEM\Setup\LabConfig" /v "BypassStorageCheck" /t REG_DWORD /d 1 /f 2>&1 | Write-Log 1242 | reg add "HKLM\xSYSTEM\Setup\LabConfig" /v "BypassCPUCheck" /t REG_DWORD /d 1 /f 2>&1 | Write-Log 1243 | reg add "HKLM\xSYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1 /f 2>&1 | Write-Log 1244 | reg add "HKLM\xSYSTEM\Setup\LabConfig" /v "BypassDiskCheck" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1245 | reg add "HKLM\xSYSTEM\Setup\MoSetup" /v "AllowUpgradesWithUnsupportedTPMOrCPU" /t REG_DWORD /d 1 /f 2>&1 | Write-Log 1246 | reg add "HKLM\xDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV1" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1247 | reg add "HKLM\xDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV2" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1248 | reg add "HKLM\xSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "HideUnsupportedHardwareNotifications" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1249 | reg add "HKLM\xSOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\HwReqChk" /v "HwReqChkVars" /t REG_MULTI_SZ /d "SQ_SecureBootCapable=TRUE\0SQ_SecureBootEnabled=TRUE\0SQ_TpmVersion=2\0SQ_RamMB=8192" /f 2>&1 | Write-Log 1250 | reg add "HKLM\xNTUSER\Software\Microsoft\PCHC" /v "UpgradeEligibility" /t REG_DWORD /d "1" /f 2>&1 | Write-Log 1251 | 1252 | reg unload HKLM\xDEFAULT 2>&1 | Write-Log 1253 | reg unload HKLM\xNTUSER 2>&1 | Write-Log 1254 | reg unload HKLM\xSYSTEM 2>&1 | Write-Log 1255 | reg unload HKLM\xSOFTWARE 2>&1 | Write-Log 1256 | 1257 | Invoke-DismFailsafe {Dismount-WindowsImage -Path $bootMountDir -Save} {dism /unmount-image /mountdir:$bootMountDir /commit} 1258 | Write-Host ("[OK] TPM Bypass Successful") -ForegroundColor Green 1259 | Write-Log -msg "Successfully modified boot.wim for TPM Bypass" 1260 | } 1261 | catch { 1262 | Write-Log -msg "Failed to mount boot.wim: $_" 1263 | } 1264 | finally { 1265 | $ProgressPreference = 'Continue' 1266 | } 1267 | } 1268 | else { 1269 | Write-Log -msg "TPM Bypass cancelled" 1270 | } 1271 | 1272 | # Bring back user folders 1273 | if ($buildNumber -ge 22000) { 1274 | if ($DoUserFoldersEnable) { 1275 | Write-Host ("`n[INFO] Restoring User Folders...") -ForegroundColor Cyan 1276 | 1277 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" /f 2>&1 | Write-Log 1278 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" /f 2>&1 | Write-Log 1279 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" /f 2>&1 | Write-Log 1280 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" /f 2>&1 | Write-Log 1281 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" /f 2>&1 | Write-Log 1282 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" /f 2>&1 | Write-Log 1283 | 1284 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" /v "HideIfEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1285 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" /v "HideIfEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1286 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" /v "HideIfEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1287 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" /v "HideIfEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1288 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" /v "HideIfEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1289 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" /v "HideIfEnabled" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1290 | 1291 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" /v "HiddenByDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1292 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" /v "HiddenByDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1293 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" /v "HiddenByDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1294 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" /v "HiddenByDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1295 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" /v "HiddenByDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1296 | reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" /v "HiddenByDefault" /t REG_DWORD /d "0" /f 2>&1 | Write-Log 1297 | 1298 | Write-Host ("[OK] User Folders Restored") -ForegroundColor Green 1299 | Write-Log -msg "User folders restored successfully" 1300 | } else { 1301 | Write-Log -msg "User folders restoration cancelled" 1302 | } 1303 | } 1304 | 1305 | Write-Host ("`n[INFO] Unloading Registry...") -ForegroundColor Cyan 1306 | Write-Log -msg "Unloading registry" 1307 | reg unload HKLM\zCOMPONENTS 2>&1 | Write-Log 1308 | reg unload HKLM\zDEFAULT 2>&1 | Write-Log 1309 | reg unload HKLM\zNTUSER 2>&1 | Write-Log 1310 | reg unload HKLM\zSOFTWARE 2>&1 | Write-Log 1311 | reg unload HKLM\zSYSTEM 2>&1 | Write-Log 1312 | Write-Host ("[OK] Success") -ForegroundColor Green 1313 | 1314 | # Integrate Intel RST/VMD Drivers 1315 | if ($DoDriverIntegrate) { 1316 | Write-Host ("`n[INFO] Integrating Intel RST/VMD Drivers...") -ForegroundColor Cyan 1317 | Write-Host (" This may take some time") -ForegroundColor DarkGray 1318 | Write-Log -msg "Starting Intel RST/VMD driver integration" 1319 | 1320 | Test-InternetConnection | Out-Null 1321 | 1322 | $driverTempPath = "$env:SystemDrive\WIDTemp\drivers" 1323 | $driverZipPath = "$driverTempPath\drivers.zip" 1324 | $driverExtractPath = "$driverTempPath\extracted" 1325 | $DriverURL = "https://github.com/itsNileshHere/Windows-ISO-Debloater/archive/refs/heads/main.zip" 1326 | 1327 | try { 1328 | # Create temp directories 1329 | New-Item -ItemType Directory -Path $driverTempPath -Force 2>&1 | Write-Log 1330 | New-Item -ItemType Directory -Path $driverExtractPath -Force 2>&1 | Write-Log 1331 | 1332 | # Download drivers 1333 | Write-Host " - Downloading drivers..." -ForegroundColor DarkGray 1334 | $ProgressPreference = 'SilentlyContinue' 1335 | try { 1336 | Invoke-WebRequest -Uri $DriverURL -OutFile $driverZipPath -UseBasicParsing -ErrorAction Stop 1337 | } 1338 | catch { 1339 | Write-Host "Failed to download drivers" -ForegroundColor Red 1340 | Write-Log -msg "Driver download failed: $_" 1341 | return 1342 | } 1343 | finally { 1344 | $ProgressPreference = 'Continue' 1345 | } 1346 | 1347 | # Verify download 1348 | if (-not (Test-Path $driverZipPath)) { 1349 | Write-Host "Driver download failed - file not found" -ForegroundColor Red 1350 | Write-Log -msg "Driver zip file not found at: $driverZipPath" 1351 | return 1352 | } 1353 | Write-Log -msg "Drivers downloaded to $driverZipPath" 1354 | 1355 | # Extract drivers 1356 | Write-Host " - Extracting drivers..." -ForegroundColor DarkGray 1357 | try { 1358 | Expand-Archive -Path $driverZipPath -DestinationPath $driverExtractPath -Force -ErrorAction Stop 1359 | } 1360 | catch { 1361 | Write-Host "Failed to extract drivers" -ForegroundColor Red 1362 | Write-Log -msg "Driver extraction failed: $_" 1363 | return 1364 | } 1365 | Write-Log -msg "Drivers extracted to $driverExtractPath" 1366 | 1367 | # Get and verify driver path 1368 | $driverSourcePath = Join-Path $driverExtractPath "Windows-ISO-Debloater-main\Drivers" 1369 | if (-not (Test-Path $driverSourcePath)) { 1370 | Write-Host "Driver folder not found in extracted files" -ForegroundColor Red 1371 | Write-Log -msg "Driver folder not found at: $driverSourcePath" 1372 | return 1373 | } 1374 | Write-Log -msg "Driver source path verified: $driverSourcePath" 1375 | 1376 | # Add drivers to install.wim 1377 | Write-Host " - Adding drivers to install.wim..." -ForegroundColor DarkGray 1378 | Invoke-DismFailsafe {Add-WindowsDriver -Path $installMountDir -Driver $driverSourcePath -Recurse -ForceUnsigned} {dism /image:$installMountDir /Add-Driver /driver:$driverSourcePath /recurse /ForceUnsigned} 1379 | Write-Log -msg "Drivers added to install.wim" 1380 | 1381 | # Add drivers to boot.wim 1382 | Write-Host " - Adding drivers to boot.wim..." -ForegroundColor DarkGray 1383 | $bootWimPath = Join-Path $destinationPath "sources\boot.wim" 1384 | $bootMountDir = "$env:SystemDrive\WIDTemp\mountdir\bootWIM" 1385 | New-Item -ItemType Directory -Path $bootMountDir -Force 2>&1 | Write-Log 1386 | 1387 | # Mount boot.wim, Add drivers, and unmount 1388 | Invoke-DismFailsafe {Mount-WindowsImage -ImagePath $bootWimPath -Index 2 -Path $bootMountDir} {dism /mount-image /imagefile:$bootWimPath /index:2 /mountdir:$bootMountDir} 1389 | Invoke-DismFailsafe {Add-WindowsDriver -Path $bootMountDir -Driver $driverSourcePath -Recurse -ForceUnsigned} {dism /image:$bootMountDir /Add-Driver /driver:$driverSourcePath /recurse /ForceUnsigned} 1390 | Invoke-DismFailsafe {Dismount-WindowsImage -Path $bootMountDir -Save} {dism /unmount-image /mountdir:$bootMountDir /commit} 1391 | 1392 | Write-Log -msg "Drivers added to boot.wim" 1393 | 1394 | Write-Host ("[OK] Driver integration completed") -ForegroundColor Green 1395 | Write-Log -msg "Driver integration completed" 1396 | } 1397 | catch { 1398 | Write-Host "Driver integration failed - skipping" -ForegroundColor Red 1399 | Write-Log -msg "Driver integration failed: $_" 1400 | } 1401 | finally { 1402 | Remove-Item -Path $driverTempPath -Recurse -Force -ErrorAction SilentlyContinue 2>&1 | Write-Log 1403 | } 1404 | } 1405 | else { 1406 | Write-Log -msg "Driver integration skipped" 1407 | } 1408 | 1409 | # Unmounting and cleaning up the image 1410 | Write-Host ("`n[INFO] Cleaning up image...") -ForegroundColor Cyan 1411 | Write-Log -msg "Cleaning up image" 1412 | Invoke-DismFailsafe {Repair-WindowsImage -Path $installMountDir -StartComponentCleanup -ResetBase} {dism /image:$installMountDir /Cleanup-Image /StartComponentCleanup /ResetBase} 1413 | 1414 | Write-Host ("`n[INFO] Unmounting and Exporting image...") -ForegroundColor Cyan 1415 | Write-Log -msg "Unmounting image" 1416 | try { 1417 | Invoke-DismFailsafe {Dismount-WindowsImage -Path $installMountDir -Save} {dism /unmount-image /mountdir:$installMountDir /commit} 1418 | Write-Log -msg "Image unmounted successfully" 1419 | } 1420 | catch { 1421 | Write-Host "`n`nFailed to Unmount the Image. Check Logs for more info." -ForegroundColor Red 1422 | Write-Host "Close all the Folders opened in the mountdir to complete the Script." 1423 | Write-Host "Run the following code in Powershell(as admin) to unmount the broken image: " 1424 | Write-Host "Dismount-WindowsImage -Path $installMountDir -Discard" -ForegroundColor Yellow 1425 | Write-Log -msg "Failed to unmount image: $_" 1426 | Pause 1427 | Exit 1428 | } 1429 | 1430 | Write-Log -msg "Exporting image" 1431 | $tempWimPath = "$destinationPath\sources\install_temp.wim" 1432 | $exportSuccess = $false 1433 | 1434 | if ($DoESDConvert) { 1435 | Write-Host ("`n[INFO] Compressing image to esd...") -ForegroundColor Cyan 1436 | Write-Log -msg "Compressing image to esd" 1437 | try { 1438 | $process = Start-Process -FilePath "dism.exe" -ArgumentList "/Export-Image /SourceImageFile:`"$destinationPath\sources\install.wim`" /SourceIndex:$sourceIndex /DestinationImageFile:`"$tempWimPath`" /Compress:Recovery /CheckIntegrity" -Wait -NoNewWindow -PassThru 1439 | if ($process.ExitCode -eq 0 -and (Test-Path $tempWimPath)) { 1440 | $exportSuccess = $true 1441 | Write-Host ("[OK] Compression completed") -ForegroundColor Green 1442 | Write-Log -msg "Compression completed" 1443 | } else { 1444 | Write-Host "Compression failed with exit code: $($process.ExitCode)" -ForegroundColor Red 1445 | Write-Log -msg "Compression failed with exit code: $($process.ExitCode)" 1446 | } 1447 | } catch { 1448 | Write-Host "Compression failed with error: $_" -ForegroundColor Red 1449 | Write-Log -msg "Compression failed with error: $_" 1450 | } 1451 | } 1452 | else { 1453 | Write-Host ("`n[INFO] Exporting image to wim...") -ForegroundColor Cyan 1454 | Write-Log -msg "Exporting image to wim" 1455 | try { 1456 | Invoke-DismFailsafe {Export-WindowsImage -SourceImagePath "$destinationPath\sources\install.wim" -SourceIndex $sourceIndex -DestinationImagePath $tempWimPath -CompressionType Maximum -CheckIntegrity} {dism /Export-Image /SourceImageFile:$destinationPath\sources\install.wim /SourceIndex:$sourceIndex /DestinationImageFile:$tempWimPath /compress:max} 1457 | if (Test-Path $tempWimPath) { 1458 | $exportSuccess = $true 1459 | Write-Host ("[OK] Export completed successfully") -ForegroundColor Green 1460 | Write-Log -msg "Export completed successfully" 1461 | } else { 1462 | Write-Host "Export failed - temp WIM not found" -ForegroundColor Red 1463 | Write-Log -msg "Export failed - temp WIM not found" 1464 | } 1465 | } catch { 1466 | Write-Host "Export failed with error: $_" -ForegroundColor Red 1467 | Write-Log -msg "Export failed with error: $_" 1468 | } 1469 | } 1470 | 1471 | if ($exportSuccess) { 1472 | Remove-Item -Path "$destinationPath\sources\install.wim" -Force 1473 | Move-Item -Path $tempWimPath -Destination "$destinationPath\sources\install.wim" -Force 1474 | 1475 | if (-not (Test-Path "$destinationPath\sources\install.wim")) { 1476 | Write-Host "Error: Unable to create the WIM file. Check logs for details." -ForegroundColor Red 1477 | Write-Log -msg "Final install.wim missing" 1478 | Pause 1479 | Exit 1480 | } else { 1481 | Write-Log -msg "WIM file successfully replaced" 1482 | } 1483 | } else { 1484 | Write-Host "Error: Unable to export modified WIM file. Check logs for details." -ForegroundColor Red 1485 | Write-Log -msg "WIM export failed, original WIM file preserved" 1486 | Pause 1487 | Exit 1488 | } 1489 | 1490 | # Verify the WIM file is accessible and valid 1491 | try { 1492 | $wimPath = Get-WindowsImage -ImagePath "$destinationPath\sources\install.wim" -ErrorAction Stop 1493 | if ($wimPath) { 1494 | Write-Host ("[OK] WIM file validation successful: $($wimPath.Count) images found") -ForegroundColor Green 1495 | Write-Log -msg "WIM validation passed: $($wimPath.Count) images found" 1496 | 1497 | # Force a filesystem sync to ensure all changes are written to disk 1498 | [System.IO.File]::OpenWrite("$destinationPath\sources\install.wim").Close() 1499 | # Add a small delay to ensure file operations are complete 1500 | Start-Sleep -Seconds 3 1501 | } else { 1502 | Write-Warning "WIM file validation returned no images" 1503 | Write-Log -msg "WIM validation warning: No images returned" 1504 | } 1505 | } catch { 1506 | Write-Host "Error: WIM file validation failed - $($_)" -ForegroundColor Red 1507 | Write-Log -msg "WIM validation failed: $_" 1508 | } 1509 | 1510 | Write-Log -msg "Checking required files" 1511 | if ($outputISO) { 1512 | $ISOFileName = ($ISOFileName -replace '[<>:"/\\|?*\x00-\x1F\s]', '').Trim() 1513 | $ISOFileName = [System.IO.Path]::GetFileNameWithoutExtension($outputISO) 1514 | } else { 1515 | do { 1516 | $ISOFileName = Read-Host -Prompt "`nEnter the name for the ISO file (without extension)" 1517 | 1518 | # Remove invalid characters 1519 | $ISOFileName = ($ISOFileName -replace '[<>:"/\\|?*\x00-\x1F\s]', '').Trim() 1520 | if ([string]::IsNullOrWhiteSpace($ISOFileName)) { 1521 | Write-Warning "Filename is empty or invalid. Please enter a valid name." 1522 | } 1523 | } while ([string]::IsNullOrWhiteSpace($ISOFileName)) 1524 | } 1525 | $ISOFile = Join-Path -Path $scriptDirectory -ChildPath "$ISOFileName.iso" 1526 | Write-Log -msg "ISO file name set to: $ISOFileName.iso" 1527 | 1528 | if ($DoUseOscdimg) { 1529 | if (-not (Test-Path -Path $Oscdimg)) { 1530 | Write-Log -msg "Oscdimg.exe not found at '$Oscdimg'" 1531 | Write-Host "`nOscdimg.exe not found at '$Oscdimg'." -ForegroundColor Red 1532 | Write-Host "`nTrying to Download oscdimg.exe..." -ForegroundColor Cyan 1533 | 1534 | Test-InternetConnection | Out-Null 1535 | 1536 | # Downloading Oscdimg.exe 1537 | # Courtesy: https://github.com/p0w3rsh3ll/ADK 1538 | $ADKfolder = "$scriptDirectory\ADKDownload" 1539 | $CabFileName = "5d984200acbde182fd99cbfbe9bad133.cab" 1540 | $ExtractedFileName = "fil720cc132fbb53f3bed2e525eb77bdbc1" 1541 | 1542 | New-Item -ItemType Directory -Path $OscdimgPath -Force 2>&1 | Write-Log 1543 | New-Item -ItemType Directory -Path $ADKfolder -Force 2>&1 | Write-Log 1544 | 1545 | # Resolve the URL 1546 | $RedirectResponse = Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2290227" -MaximumRedirection 0 -UseBasicParsing -ErrorAction SilentlyContinue 1547 | if ($RedirectResponse.StatusCode -eq 302) { 1548 | $BaseURL = $RedirectResponse.Headers.Location.TrimEnd('/') + "/" 1549 | $CabURL = "$BaseURL`Installers/$CabFileName" 1550 | $CabFilePath = "$ADKfolder\$CabFileName" 1551 | 1552 | Write-Log -msg "Downloading CAB file from: $CabURL" 1553 | Invoke-WebRequest -Uri $CabURL -OutFile $CabFilePath -UseBasicParsing 1554 | 1555 | # Extract the CAB file 1556 | Write-Log -msg "Extracting CAB file..." 1557 | expand.exe -F:* $CabFilePath $ADKfolder 2>&1 | Write-Log 1558 | 1559 | # Move the required file 1560 | $ExtractedFilePath = "$ADKfolder\$ExtractedFileName" 1561 | $FinalFilePath = "$OscdimgPath\oscdimg.exe" 1562 | 1563 | if (Test-Path $ExtractedFilePath) { 1564 | Move-Item -Path $ExtractedFilePath -Destination $FinalFilePath -Force 2>&1 | Write-Log 1565 | Write-Host "Oscdimg.exe downloaded successfully" -ForegroundColor Green 1566 | Write-Log -msg "Oscdimg.exe successfully placed in: $OscdimgPath" 1567 | } 1568 | else { 1569 | Write-Log -msg "Error: Extracted file not found!" 1570 | } 1571 | } 1572 | else { 1573 | Write-Host "Error: Failed to download Oscdimg.exe" -ForegroundColor Red 1574 | Write-Log -msg "Failed to resolve ADK download link. HTTP Status: $($RedirectResponse.StatusCode)" 1575 | Remove-TempFiles 1576 | Pause 1577 | Exit 1578 | } 1579 | } 1580 | 1581 | # Generate ISO 1582 | Write-Host ("`n[INFO] Generating ISO...") -ForegroundColor Cyan 1583 | Write-Log -msg "Generating ISO using OSCDIMG" 1584 | try { 1585 | $etfsbootPath = "$destinationPath\boot\etfsboot.com" 1586 | $efisysPath = "$destinationPath\efi\Microsoft\boot\efisys.bin" 1587 | $bootData = "2#p0,e,b`"$etfsbootPath`"#pEF,e,b`"$efisysPath`"" 1588 | Write-Log -msg "Boot data set: $bootData" 1589 | 1590 | $oscdimgArgs = @( 1591 | "-bootdata:$bootData", 1592 | "-m", # Ignore maximum size limit 1593 | "-o", # Optimize for space 1594 | "-h", # Show hidden files 1595 | "-u2", # UDF 2.0 1596 | "-udfver102", # UDF version 1.02 1597 | "-l$ISOFileName", # Set volume label 1598 | "`"$destinationPath`"", 1599 | "`"$ISOFile`"" 1600 | ) 1601 | 1602 | Write-Log -msg "OSCDIMG command: $Oscdimg $($oscdimgArgs -join ' ')" 1603 | $oscdimgProcess = Start-Process -FilePath "$Oscdimg" -ArgumentList $oscdimgArgs -PassThru -Wait -NoNewWindow 1604 | 1605 | if ($oscdimgProcess.ExitCode -eq 0) { 1606 | Write-Host ("[OK] ISO creation successful") -ForegroundColor Green 1607 | Write-Log -msg "ISO successfully created with exit code 0" 1608 | } else { 1609 | Write-Warning "ISO creation finished with errors" 1610 | Write-Log -msg "OSCDIMG exited with code: $($oscdimgProcess.ExitCode)" 1611 | } 1612 | } 1613 | catch { 1614 | Write-Log -msg "Failed to generate ISO with exit code: $_" 1615 | } 1616 | } 1617 | else { 1618 | Write-Host "`n[INFO] Preparing ISO creation..." -ForegroundColor Cyan 1619 | Write-Log -msg "Preparing ISO creation" 1620 | 1621 | # ISOWriter class 1622 | # More Here: https://learn.microsoft.com/en-us/windows/win32/api/_imapi/ 1623 | if (!('ISOWriter' -as [Type])) { 1624 | Add-Type -TypeDefinition @' 1625 | using System; 1626 | using System.Runtime.InteropServices; 1627 | using System.Runtime.InteropServices.ComTypes; 1628 | 1629 | public class ISOWriter { 1630 | [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)] 1631 | private static extern void SHCreateStreamOnFileEx(string fileName, uint mode, uint attributes, bool create, IStream streamNull, out IStream stream); 1632 | public static bool Create(string filePath, ref object imageStream, int blockSize, int totalBlocks) {IStream resultStream = (IStream)imageStream, imageFile; SHCreateStreamOnFileEx(filePath, 0x1001, 0x80, true, null, out imageFile); const int bufferSize = 1024; int remainingBlocks = totalBlocks; 1633 | while (remainingBlocks > 0) { int blocksToWrite = Math.Min(remainingBlocks, bufferSize); resultStream.CopyTo(imageFile, blocksToWrite * blockSize, IntPtr.Zero, IntPtr.Zero); remainingBlocks -= blocksToWrite;} 1634 | imageFile.Commit(0); 1635 | return true;} 1636 | } 1637 | '@ 1638 | } 1639 | 1640 | try { 1641 | $comObjects = @() 1642 | 1643 | # Initialize boot configuration 1644 | $bootStream = New-Object -ComObject ADODB.Stream -Property @{ Type = 1 } 1645 | $comObjects += $bootStream 1646 | $bootStream.Open() 1647 | $bootStream.LoadFromFile("$destinationPath\efi\Microsoft\boot\efisys.bin") 1648 | # $bootStream.LoadFromFile("$destinationPath\efi\Microsoft\boot\efisys_noprompt.bin") 1649 | 1650 | # Configure boot and filesystem 1651 | $bootOptions = New-Object -ComObject IMAPI2FS.BootOptions -Property @{ 1652 | PlatformId = 0xEF 1653 | Manufacturer = "Microsoft" 1654 | Emulation = 0 1655 | } 1656 | $comObjects += $bootOptions 1657 | $bootOptions.AssignBootImage($bootStream) 1658 | 1659 | $FSImage = New-Object -ComObject IMAPI2FS.MsftFileSystemImage -Property @{ 1660 | FileSystemsToCreate = 4 1661 | UDFRevision = 0x102 1662 | FreeMediaBlocks = 0 1663 | VolumeName = $ISOFileName 1664 | } 1665 | $comObjects += $FSImage 1666 | 1667 | Write-Log -msg "Creating ISO structure" 1668 | $FSImage.Root.AddTree($destinationPath, $false) 1669 | $FSImage.BootImageOptions = $bootOptions 1670 | 1671 | Write-Host "[INFO] Generating ISO..." -ForegroundColor Cyan 1672 | Write-Log -msg "Generating ISO using ISOWriter" 1673 | $resultImage = $FSImage.CreateResultImage() 1674 | $comObjects += $resultImage 1675 | 1676 | [ISOWriter]::Create($ISOFile, [ref]$resultImage.ImageStream, $resultImage.BlockSize, $resultImage.TotalBlocks) | Out-Null 1677 | 1678 | if ((Get-Item $ISOFile).Length -eq ($resultImage.BlockSize * $resultImage.TotalBlocks)) { 1679 | Write-Log -msg "ISO successfully created at: $ISOFile" 1680 | } 1681 | } 1682 | catch { 1683 | Write-Log -msg "ISO creation failed: $_" -Type Error 1684 | } 1685 | finally { 1686 | foreach ($obj in $comObjects) { 1687 | if ($obj) { 1688 | while ([Runtime.InteropServices.Marshal]::ReleaseComObject($obj) -gt 0) { } 1689 | } 1690 | } 1691 | [GC]::Collect() 1692 | [GC]::WaitForPendingFinalizers() 1693 | Write-Host "[OK] ISO creation successful" -ForegroundColor Green 1694 | } 1695 | } 1696 | 1697 | # ISO verification 1698 | if (Test-Path -Path $ISOFile) { 1699 | try { 1700 | $verifyMntResult = Mount-DiskImage -ImagePath "$ISOFile" -PassThru 1701 | $verifyDrive = ($verifyMntResult | Get-Volume).DriveLetter 1702 | $isoMountPoint = "${verifyDrive}:\" 1703 | $reqFiles = @("sources\install.wim", "sources\boot.wim", "boot\bcd", "boot\boot.sdi", "bootmgr", "bootmgr.efi", "efi\microsoft\boot\efisys.bin") 1704 | $missingFiles = $reqFiles | Where-Object { -not (Test-Path (Join-Path $isoMountPoint $_)) } 1705 | 1706 | Dismount-DiskImage -ImagePath "$ISOFile" 2>&1 | Write-Log 1707 | 1708 | if ($missingFiles) { 1709 | Write-Host "`nError: Created ISO is missing critical files" -ForegroundColor Red 1710 | Write-Log -msg "ISO verification failed - missing files: $($missingFiles -join ', ')" 1711 | } 1712 | else { 1713 | Write-Host "`nScript Completed. Can find the ISO in `"$scriptDirectory`"" -ForegroundColor Green 1714 | Write-Log -msg "ISO verification successful" 1715 | } 1716 | } 1717 | catch { 1718 | Write-Warning "`nUnable to verify ISO integrity" 1719 | Write-Log -msg "Failed to verify ISO: $_" 1720 | } 1721 | } else { 1722 | Write-Host "`nError: ISO file wasn't created" -ForegroundColor Red 1723 | Write-Log -msg "ISO file wasn't created" 1724 | } 1725 | 1726 | # Remove temporary files 1727 | Write-Log -msg "Removing temporary files" 1728 | try { 1729 | Remove-TempFiles 1730 | } 1731 | catch { 1732 | Write-Log -msg "Failed to remove temporary files: $_" 1733 | } 1734 | finally { 1735 | Write-Log -msg "Script completed" 1736 | } 1737 | 1738 | Write-Host 1739 | Pause --------------------------------------------------------------------------------