设置"图像文件执行选项"将始终打开命名的exe文件作为默认值

C.C*_*.C. 9 registry

由于这个链接提示,我想更换Notepad.exeNotepad2.exe使用" 图像文件执行选项 "通过运行该命令功能

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" 
      /v "Debugger" /t REG_SZ /d "\"c:\windows\Notepad2.exe\" /z" /f
Run Code Online (Sandbox Code Playgroud)

但是当我运行记事本时,它仍会打开文件

C:\ WINDOWS\NOTEPAD.EXE

默认情况下,在notepad2.exe中作为文本文件.

有没有办法避免这种情况?

我知道使用这个技术Notepad.exe将作为传递给Notepad2.exe的第一个参数.但我不知道如何避免这种情况:(

Ben*_*n L 15

"调试器"键的目的是自动启动调试器并将原始命令行传递给所需的调试器.它还在win32函数CreateProcess上设置一个标志,指示这是一个调试会话.

暗示调试器将在适当修改参数后调用CreateProcess.

>notepad.exe "\document1.txt"
Run Code Online (Sandbox Code Playgroud)

变成

>mydebugger.exe notepad.exe "\document1.txt"
Run Code Online (Sandbox Code Playgroud)

mydebugger可以调用这样的东西:

BOOL res = CreateProcess( NULL, L"notepad.exe \"\\document1.txt\", NULL, NULL,
                          FALSE, cFlags, env, NULL, startupInfo, procInfo&);
Run Code Online (Sandbox Code Playgroud)

因此,滥用此注册表项的解决方案是使伪调试器能够以您希望的方式操作命令行.它应该是一个简单的过程,只需解析命令行并用notepad2.exe替换notepad.exe.然后,您需要将注册表指向该.exe


use*_*801 7

Notepad Replacer使用此技术,但使其非常易于使用,并可与不支持调试器的编辑器一起使用。

  • 闻起来像垃圾邮件,是吗?无论如何,问题是_how_(不是_哪个工具_) (2认同)
  • 我认为“如何”的最佳答案是使用我建议的工具,这实际上是最高投票答案所建议的实现(并留给读者练习)`滥用此注册表项的解决方案是制作可以按照您希望的方式操作命令行的假调试器。它应该是一个简单的过程,只需解析命令行并将notepad.exe 替换为notepad2.exe。然后你需要将注册表指向那个 .exe` (2认同)

fen*_*ter 1

这里 用 Notepad2 4.1.24(或更高版本)替换 Windows 记事本

从 4.1.24 版本开始,Notepad2 正式版支持这种替换 Windows 记事本的方法,因此上述步骤可以正常工作。不过,不支持自动执行Notepad替换,因为正式发布的Notepad2不会修改系统注册表。出于同样的原因,默认情况下不支持通过 Windows 7 跳转列表访问最近的文件(这需要首先在系统注册表中注册应用程序)。

另请注意,如果将 Notepad2 用作便携式设备的记事本替代品,并且断开设备连接时不会恢复原始状态,则自动记事本更换可能会产生不良影响。

从 Notepad2 目录运行并替换 Windows 记事本的批处理脚本可能如下所示(需要提升的权限):

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%~dp0Notepad2.exe\" /z" /f

可以使用以下命令恢复 Windows 记事本(需要提升权限):

reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f

通过打开 Regedit 并查看来验证结果[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]。调试器键应包含 notepad2.exe 的完整路径并包含尾随的/z,例如:

c:\local\bin\Notepad2.exe /z
Run Code Online (Sandbox Code Playgroud)