1.vbs系统右键新建菜单选项 添加 新建 vbs文件选项
filetype=".vbs"
' connect to WScript..Shell for registry access
set WSHShell = CreateObject("WScript.Shell")
' read in the name of the vbs-section
prg = ReadReg("HKCR\" & filetype & "\")
MsgBox prg
' read in the official name for vbs-files
prgname = ReadReg("HKCR\" & prg & "\")
MsgBox prgname
' ask for a new name
ask = "new VBScript scripts"
title = "New menu emtry"
prgname = InputBox(ask,title,prgname)
' save the new program description
WSHShell.RegWrite "HKCR\" & prg & "\",prgname
' add a new menu entry asking for an empty new file;
WSHShell.RegWrite "HKCR\" & filetype & "\ShellNew\NullFile","123"
'reads a registr key
'should the key be invalid,complain and stop;
function ReadReg(key)
on error resume next
ReadReg = WSHShell.RegRead(key)
if err.Number>0 then
' key cound not be read :complain!
error = "Error:Registry.Key" & key _
& "cound not be found"
MsgBox error.vbCritical
WScript.Quit
end if
end function
2.效果如下:
3.去除菜单选项
set WSHShell = CreateObject("WScript.Shell")
filetype=".vbs"
WSHShell.RegDelete "HKCR\" & filetype & "\ShellNew\"
MsgBox "Command removed!"