Skip to content

Instantly share code, notes, and snippets.

@wincmd64
Last active October 20, 2024 11:12
Show Gist options
  • Save wincmd64/aa1c1e97cb67f37d637df4d471ba5922 to your computer and use it in GitHub Desktop.
Save wincmd64/aa1c1e97cb67f37d637df4d471ba5922 to your computer and use it in GitHub Desktop.
:: Replacing default notepad.exe with your editor
:: https://t.me/wincmd64
@echo off
(Net session >nul 2>&1)&&(cd /d "%~dp0")||(PowerShell start """%~0""" -verb RunAs & Exit /B)
:: path to your editor
SET "NOTEPAD_PATH=%ProgramFiles%\Notepad++\notepad++.exe"
echo Set "%NOTEPAD_PATH%" as default editor? & echo. & pause
@echo on
:: use "\"%NOTEPAD_PATH%\" /z" for AkelPad
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%NOTEPAD_PATH%\" -notepadStyleCmdline -z" /f
:: check if win11
for /f %%a in ('powershell.exe -NoP -NoL -NonI -EP Bp -c "(gwmi Win32_OperatingSystem).Caption -Replace '\D'"') do (
if "%%a"=="11" goto 11
)
pause & exit
:11
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\0" /v "FilterFullPath" /t REG_SZ /d "%NOTEPAD_PATH%" /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\1" /v "FilterFullPath" /t REG_SZ /d "%NOTEPAD_PATH%" /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\2" /v "FilterFullPath" /t REG_SZ /d "%NOTEPAD_PATH%" /f
powershell -Command "Get-AppxPackage *Microsoft.WindowsNotepad* | Remove-AppxPackage"
pause & exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment