Replacing Notepad with Notepad 2
UPDATE: This post applies to Windows Vista, although comments indicate that it works on XP despite a few warnings.
I've been playing with IronPython and IronRuby the past week or two. To get basic syntax highlighting, I use the Notepad2 text editor since Visual Studio doesn't really support the dynamic languages yet (unless you download something like IronPythonStudio, which I do like) and Notepad is about as close to worthless as you can get in a text editor these days. My goal is to completely replace the default Notepad text editor so that the replacement (Notepad2) opens as the default text editor everywhere in Windows, even if you "View Source" from a web page.
<rant>
Seriously, when was the last time Notepad was updated? Windows '98? Does anyone find it reasonable that it is 2008 and my text editor choices that ship with Windows Vista are Notepad (a text editor so basic that it still doesn't support line numbers) and Wordpad (a useless middle child that messes with my doc too much to code in and sucks too bad to replace MS Word)?
</rant>
Among Notepad replacements, my favorites are Notepad2 and Notepad++. I usually stick with Notepad2 but either works. Since Windows keeps backups of Notepad and now UAC protects the documents, it can be a bit difficult to replace the default Notepad. There are some methods involving copying the file around over system files that never seems to work for me. I found an awesome batch file on the "My Digital Life" forum that you can use to easily install Notepad2 and override the copies and UAC but I'm always losing it so I'm putting it up here as well. So, to install Notepad2:
- Download Notepad2
- Extract it to a folder.
- Create two batch files in the same folder as Notepad2. I usually just call them install.bat and uninstall.bat
- Put the following code in install.bat and save it.
@echo off
TITLE Notepad2 Install Script for Complete Vista Notepad Replacement
echo.
echo Notepad2 Install Script for Complete Vista Notepad Replacement
echo Version 1.1
echo.
echo (c) My Digital Life (www.mydigitallife.info)
echo.
echo.
echo.
echo Confirm to apply? (Press Ctrl-C and answer Y to terminate)
pause
echo.
echo.
if exist %Systemroot%\notepad.original.exe goto exist_notepad2_already
if exist %Systemroot%\System32\notepad.original.exe goto exist_notepad2_already
takeown /f %Systemroot%\notepad.exe
takeown /f %Systemroot%\System32\notepad.exe
icacls %Systemroot%\notepad.exe /grant "%username%":f
icacls %Systemroot%\System32\notepad.exe /grant "%username%":f
IF EXIST %SYSTEMROOT%\SysWOW64 (bcdedit.exe -set loadoptions "DDISABLE_INTEGRITY_CHECKS")
copy %Systemroot%\notepad.exe %Systemroot%\notepad.original.exe
copy %Systemroot%\System32\notepad.exe %Systemroot%\System32\notepad.original.exe
echo.
echo Original notepad.exe has been renamed to "notepad.original.exe" in its original folder.
echo.
copy notepad2.exe %Systemroot%\notepad.exe /y
copy notepad2.exe %systemroot%\System32\notepad.exe /y
echo.
echo Notepad2 installation is completed.
echo If no error occurred, Notepad2 will now replace all Notepad functions.
echo.
pause
exit
:exist_notepad2_already
echo.
echo INSTALLED NOTEPAD2 ALREADY!.
echo.
pause
exit
- Put the following code in uninstall.bat and save it.
@echo off
TITLE Notepad2 UnInstall Script for Complete Vista Notepad Replacement
echo.
echo Notepad2 UnInstall Script for Complete Vista Notepad Replacement
echo Version 1.1
echo.
echo (c) My Digital Life (www.mydigitallife.info)
echo.
echo.
echo.
echo Confirm to apply? (Press Ctrl-C and answer Y to terminate)
pause
echo.
echo.
if not exist %Systemroot%\notepad.original.exe goto not_exist_notepad2
if not exist %Systemroot%\System32\notepad.original.exe goto not_exist_notepad2
takeown /f %Systemroot%\notepad.exe
takeown /f %Systemroot%\System32\notepad.exe
icacls %Systemroot%\notepad.exe /grant "%username%":f
icacls %Systemroot%\System32\notepad.exe /grant "%username%":f
IF EXIST %SYSTEMROOT%\SysWOW64 (bcdedit.exe -set loadoptions "DDISABLE_INTEGRITY_CHECKS")
del %Systemroot%\notepad.exe
del %Systemroot%\System32\notepad.exe
echo.
echo notepad.exe(notepad2) has been deleted.
echo.
ren %Systemroot%\notepad.original.exe notepad.exe
ren %Systemroot%\System32\notepad.original.exe notepad.exe
echo.
echo Original notepad.original.exe has been renamed to "notepad.exe" in its original folder.
echo.
echo Notepad2 uninstallation is completed.
echo.
goto exit_uninstall
:not_exist_notepad2
echo.
echo ERROR NOTEPAD2 NOT EXIST or NOT INSTALL.
goto exit_uninstall
:exit_uninstall
pause
- Navigate to the directory you put Notepad2 and the batch files in and just run install.bat or uninstall.bat (for whichever operation you'd like) as Administrator. The easiest way to do this is to right click the file you'd like to run while holding the left shift key, then clicking "Run as Administrator".
After that, your new Notepad editor should be set up. Just type Notepad and see what comes up. Enjoy.