Notepad2 uses the following trick to replace the original Windows Notepad.
In summary it uses Windows' image execution options to redirect calls from Notepad.exe to C:\\Program Files\\Notepad2\\Notepad2.exe /z
-- the option /z
tells Notepad2 to ignore argv[1]
and concatenate the rest of the arguments into a single filename.
In doing the above for SciTE, the following is my progress so far. The purpose of this thread is to kindly ask the author of SciTE to implement Notepad2's methods such that I can get rid of the kludge below:
Added to registry:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]
"Debugger"="\"C:\\Windows\\System32\\wscript.exe\" \"C:\\Scripts\\SciteRunner.vbs\""
C:\Scripts\SciteRunner.vbs:
Dim FileName, CmdLine
For I = 1 To WScript.Arguments.Count - 1
FileName = FileName & WScript.Arguments.Item(I)
If I <> WScript.Arguments.Count - 1 Then
FileName = FileName & " "
End If
Next
FileName = Replace(FileName, "\", "\\")
CmdLine = """C:\wscite\SciTE.exe"" ""-open:" & FileName & """"
CreateObject("WScript.Shell").Run CmdLine, 0, True
There is an additional functionality from Notepad2 that I would like to see in SciTE: take into account the current work directory without requiring the -cwd:
option. Currently SciTE ignores the start directory -- this can be verified by creating a link to SciTE.exe and changing the "Start in:" field -- SciTE will try so Save As in the previously used directory.
I don't understand the explanation here and would prefer to see a patch.
https://github.com/zufuliu/notepad2/wiki/System-Integration#replace-windows-notepad-via-registry
/z
tells Notepad2 to skip next parameter (path for Windows Notepad.exe) when user click explorer's Edit, Open or Print (set extra parameter/p
) context menus. Notepad2 is invoked with following parameters:Here is code for registry changes (changes other than
Debugger
are required for Win11).https://github.com/zufuliu/notepad2/blob/main/src/Dialogs.c#L2827
Duplicate of [feature-requests:#833], which had a patch.
Related
Feature Requests: #833