How to replace notepad.exe with notepad++
Notepad++ is a pretty useful editor for Windows - if you don’t know it - you may want to take a look at it here : notepad-plus-plus.org.
However, once you are used to notepad’s alternative, you may find that it annoying that it can be quite a challenge to make windows run your chosen editor in ALL Situations.
Here’s a possible Solution :
( Tested under Windows 7,8,8.1 x86 and x64 )
How to use
The Launcher functions by adding a registry key which causes Windows to intercept attempts to execute programs of a certain name.
In our case, we want to run our script whenever notepad.exe is about to be executed, so we can then run notepad++.exe instead.
INSTALL:
Install Notepad++ (portable or regular setup) onto a fixed,non-removable drive
Copy into the Folder containing the notepad++.exe and doubleclick ( with ADMINISTRATOR rights to write the registry )
( It probably makes sense to ensure sure nobody can replace or change this script, other than the Administrator )
UNINSTALL:
Doubleclick the script and let it remove the registry entry
Manual Uninstall:
Delete the registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe
Delete the script
Changes made to your System :
Registry Key :
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger
Known Bugs
Uninstall only deletes the Debugger key
Contains only minimal Error Handling
WARNING
If you chose to use this script, you assume the full responsibility of doing so at your sole risk.
Download here
npp_start.vbs
Script to replace notepad.exe with notepad++
Listing
'// DISCLAIMER
'// THIS COMES WITH NO WARRANTY, IMPLIED OR OTHERWISE. USE AT YOUR OWN RISK
'// IF YOU ARE NOT COMFORTABLE EDITING THE REGISTRY THEN DO NOT USE THIS SCRIPT
'//
'// NOTES:
'// This affects all users.
'// This will execute for ANY notepad.exe being started on the computer,
'// but the script will try to only replace the 'standard' executables
'// This script also contains a workaround for the buggy HEX-EDITOR 0.9.5
'// Plugin, which crashes if .nfo files are opened.
'//
'// INSTALL:
'// Copy into the Folder containing the notepad++.exe and doubleclick
'// ( with ADMINISTRATOR rights)
'//
'// UNINSTALL:
'// Doubleclick
'//
'// Registry Key being modified
'// HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger
Option Explicit
Dim sCmd,tCmd, x, sArgs, known_notepad
Dim WS
Set WS = CreateObject("WScript.Shell")
tCmd = LeftB(WScript.ScriptFullName, LenB(WScript.ScriptFullName) - LenB(WScript.ScriptName)) & "notepad++.exe"
sCmd = """" & tCmd & """"
if( WScript.Arguments.Count > 1) Then
sArgs=" " & """"
For x = 1 To WScript.Arguments.Count - 1
sArgs = sArgs & WScript.Arguments(x)
if(x<WScript.Arguments.Count - 1) then
sArgs = sArgs & " "
end if
Next
sArgs=sArgs & """"
else
sArgs=""
End If
' Set known_notepad to 1 if the program called was in the original places. Add/change lines as needed.
known_notepad=0
if( WScript.Arguments.Count > 0) Then
If(StrComp(WScript.Arguments(0), "C:\Windows\notepad.exe" , vbTextCompare)) Then known_notepad=1 End If
If(StrComp(WScript.Arguments(0), "C:\Windows\System32\notepad.exe" , vbTextCompare)) Then known_notepad=1 End If
Else
' If there are no Arguments, this script was double-clicked - so find out whether it should
' install or deinstall itself.
On Error Resume Next
' Install (after asking for permission) if no registry entry exists , and notepad.exe exists
If( "" = WS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger" )) Then
If( CreateObject("Scripting.FileSystemObject").FileExists(tCmd)) Then
If( vbYES = MsgBox("Configure this script to replace notepad.exe ? ", vbYesNo)) Then
WS.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger","wscript.exe "&WScript.ScriptFullName,"REG_SZ"
MsgBox "Registry changed :" & vbNewLine & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger" & vbNewLine & "to contain" & vbNewLine & WS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger")
Else
MsgBox "Nothing changed."
End If
Else
MsgBox("File not found. " & sCmd & " Copy this script into the directory where notepad++.exe resides.")
End If
Else
' Remove (after asking for permission) if the registry entry exists
If( vbYES = MsgBox("Remove the notepad.exe replacement ? ", vbYesNo)) Then
WS.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger"
MsgBox "Registry change failed :" & vbNewLine & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger" & vbNewLine & "still exists" & vbNewLine & WS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\Debugger")
Else
MsgBox "Nothing changed."
End If
End If
On Error Goto 0
WScript.Quit
End If
' Work around crashing notepad++ when opening .nfo files
' (BUG in the HEX-Editor Plugin 0.9.5) by running notepad++ without a file first
If(not StrComp( Left(Right(sArgs,5),4), ".nf0", vbTextCompare)) Then
WS.Run sCmd , 1, False
End If
' Run the replacement if an exe in the original places was called, else run the actual program
If (known_notepad) Then
WS.Run sCmd & sArgs, 1, True
Else
WS.Run WScript.Arguments(0) & sArgs, 1, True
End If
'MsgBox("Arg(0) " & WScript.Arguments(0))
WScript.Quit