如何在 Windows 7 上将默认的 IE Html 编辑器更改为 Notepad2

如何在 Windows 7 上将默认的 IE Html 编辑器更改为 Notepad2

这样当我查看源代码时,notepad2 就会打开文档。我已经下载了 notepad2。

答案1

您可以通过直接添加/编辑来做到这一点Registry Keys

类型regedit.exe运行。

另一种方式是,以下是未测试vbscript 代码:-

NOTE: Please be careful, while playing with registry keys.

代码:

Set WshShell = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
Dim MyKey, EditorName, KeyToAdd, rtn, MyKeySelf
MyKey = Inputbox("Type the application name with full path", "Add a HTML Editor", "C:\Windows\Notepad.exe")

if trim(MyKey) = "" then WScript.Quit

MyKeySelf = """" + MyKey + """" & " " & """" + "%1" + """"

if not fs.fileexists(MyKey) then
    rtn = msgbox("Specified file is missing, do you want to continue anyway?", 36, "Add a HTML Editor")
        if rtn = 6 then
            Call AddEditor
        else
            WScript.Quit
        end if
else
    Call AddEditor
end if

Sub AddEditor()
    EditorName = fs.GetFileName(MyKey)
    KeyToAdd = "HKCR\.htm\openwithlist\" & EditorName & "\"
    WshShell.RegWrite KeyToAdd,"","REG_SZ"
    KeyToAdd = "HKCR\Applications\" & EditorName & "\shell\edit\command\"
    WshShell.RegWrite KeyToAdd,MyKeySelf,"REG_SZ"

    rtn = msgbox("Added... Do you want to set it as the default HTML Editor?", 36, "Add a HTML Editor")
    if rtn = 6 then
        Call SetAsDefaultEditor
    end if  
end sub

Sub SetAsDefaultEditor()
    On Error resume next
    KeyToAdd = "HKCU\Software\Microsoft\Internet Explorer\Default HTML Editor\shell\edit\command\"
    WshShell.RegWrite KeyToAdd,MyKeySelf,"REG_SZ"
    KeyToAdd = "HKCU\Software\Microsoft\Shared\HTML\Default Editor\shell\edit\command\"
    WshShell.RegWrite KeyToAdd,MyKeySelf,"REG_SZ"
    WshShell.Regdelete "HKCU\Software\Microsoft\Internet Explorer\Default HTML Editor\Description"
    WshShell.Regdelete "HKCU\Software\Microsoft\Internet Explorer\Default HTML Editor\shell\edit\ddeexec\Topic\"
    WshShell.Regdelete "HKCU\Software\Microsoft\Internet Explorer\Default HTML Editor\shell\edit\ddeexec\Application\"
    WshShell.Regdelete "HKCU\Software\Microsoft\Internet Explorer\Default HTML Editor\shell\edit\ddeexec\"
end sub

Set WshShell = Nothing
Set fs = Nothing

相关内容