Skip to content

Instantly share code, notes, and snippets.

@wincmd64
Created June 2, 2024 08:29
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 & CLS & ECHO.
NET FILE 1>NUL 2>NUL & IF ERRORLEVEL 1 (ECHO You must right-click and select & ECHO "RUN AS ADMINISTRATOR" to run this batch. Exiting... & ECHO. & Timeout /t 10 & EXIT /B)
:: path to your editor
SET "NOTEPAD_PATH=%ProgramFiles%\Notepad++\notepad++.exe"
echo Set "%NOTEPAD_PATH%" as default editor?
pause
@echo on
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
for /f "tokens=2 delims==" %%a in ('wmic os get Caption /value ^| findstr /C:"Caption"') do set os=%%a
echo %os% | findstr /C:"Windows 11" > nul && 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