Last active
February 25, 2026 21:30
-
-
Save gmolveau/e2aae41cd3252994e3c7e9edb84ec8f9 to your computer and use it in GitHub Desktop.
Windows 11 restore old classic notepad / disable new notepad AI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Restores the classic Windows Notepad on Windows 11 and reassociates .txt files. | |
| .DESCRIPTION | |
| This script replaces the new Notepad with the classic version. If not found in WinSxS, it unzips a provided installer and launches it. | |
| .NOTES | |
| Run this script as Administrator. | |
| #> | |
| # Check if running as Administrator | |
| if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
| Write-Host "Please run this script as Administrator." | |
| exit 1 | |
| } | |
| # Define paths | |
| $newNotepadPath = "C:\Windows\System32\notepad.exe" | |
| $backupPath = "C:\Windows\System32\notepad_new.exe" | |
| $zipPath = "notepad.zip" | |
| $installerPath = "notepad.exe" | |
| # Backup new Notepad | |
| if (Test-Path $newNotepadPath) { | |
| Rename-Item -Path $newNotepadPath -NewName "notepad_new.exe" -Force | |
| } | |
| # Try to restore classic Notepad from WinSxS | |
| $classicNotepadSource = Get-ChildItem -Path "C:\Windows\WinSxS\*" -Filter "notepad.exe" -Recurse | | |
| Where-Object { $_.VersionInfo.FileVersionRaw -lt "10.0.22000.0" } | | |
| Sort-Object -Property VersionInfo.FileVersionRaw -Descending | | |
| Select-Object -First 1 -ExpandProperty FullName | |
| if ($classicNotepadSource) { | |
| Copy-Item -Path $classicNotepadSource -Destination $newNotepadPath -Force | |
| Write-Host "Classic Notepad restored from WinSxS." | |
| } else { | |
| Write-Host "Classic Notepad not found in WinSxS. Unzipping installer..." | |
| if (Test-Path $zipPath) { | |
| Expand-Archive -Path $zipPath -DestinationPath . -Force | |
| Write-Host "Launching installer..." | |
| Start-Process -FilePath $installerPath -Wait | |
| Write-Host "Installer completed. Press any key to continue..." | |
| $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | |
| } else { | |
| Write-Host "notepad.zip not found. Please ensure the file is in the same directory as the script." | |
| exit 1 | |
| } | |
| } | |
| # Reassociate .txt files with classic Notepad | |
| Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice" -Name "ProgId" -Value "txtfile" -Force | |
| Set-ItemProperty -Path "HKCU:\Software\Classes\txtfile\shell\open\command" -Name "(Default)" -Value "`"$env:SystemRoot\System32\notepad.exe`" `"%1`"" -Force | |
| Write-Host "Classic Notepad has been restored and set as the default for .txt files. Restart your computer if needed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment