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 & "\")
' read in the official name for vbs-files:
prgname = ReadReg("HKCR\" & prg & "\")
' ask for a new name
ask = "What should be the name for new VBScript scripts?"
title = "New menu entry"
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", ""
' reads a registry 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 could not be read: complain!
error = "Error: Registry-Key """ & key _
& """ could not be found!"
MsgBox error, vbCritical
WScript.Quit
end if
end function