Board logo

标题: 在新建菜单下添加可建vb或bat等类型 [打印本页]

作者: abczxc     时间: 2007-4-29 10:57    标题: 在新建菜单下添加可建vb或bat等类型

'保存.vbs文件
'把第五行filetype = ".vbs"中的.vbs 改为.bat 就能在右键的新建菜单中看增加.bat了
' this is the file extension the new command
' should generate:
filetype = ".vbs"

set WSHShell = CreateObject("WScript.Shell")

prg = ReadReg("HKCR\" & filetype & "\")
prgname = ReadReg("HKCR\" & prg & "\")

ask = "What should be the name for new VBScript scripts?"
title = "New menu entry"
prgname = InputBox(ask, title, prgname)

WSHShell.RegWrite "HKCR\" & prg & "\", prgname
WSHShell.RegWrite "HKCR\" & filetype & "\ShellNew\NullFile", ""

function ReadReg(key)
    on error resume next
    ReadReg = WSHShell.RegRead(key)
    if err.Number>0 then
        ' key could not be read: complain!
        error = "Error: Registry-Key """ & key _
            & """ could not be found!"
        MsgBox error, vbCritical
        WScript.Quit
    end if
end function
作者: abczxc     时间: 2007-4-30 06:56
要多刷新几次就出来了
在新建菜单下多了.vbs文件了
这样真的方便多了耶
作者: zhoushijay     时间: 2007-4-30 07:12
这东西太好了,谢谢LZ,加分加分
作者: baomaboy     时间: 2007-4-30 08:04


  Quote:
Originally posted by abczxc at 2007-4-30 06:56:
要多刷新几次就出来了
在新建菜单下多了.vbs文件了
这样真的方便多了耶

不用多刷几次,第二次一定会出效果的。

另外功能类似的 管理”新建“菜单中的文件类型→VBS版