Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Operating Systems .: Windows Operating Systems .: Windows Scripts and Batch Files .: Add VBScript to New File Context Menu - Requires Local Admin Rights

Add VBScript to New File Context Menu - Requires Local Admin Rights

 

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


How helpful was this article to you?

Related Articles

article VB Script to Add Domain User to Local Administrators - Requires Local Admin Rights
  Description: Takes a domain user...

(No rating)  3-24-2008    Views: 185   
article VB Script to Block The Installation of XP Service Pack 2 - Requires Local Admin Rights
  Description: Blocks the...

(No rating)  3-24-2008    Views: 169   
article VBScript to Change Admin Password on AD Computers
The password is statically set in the...

(No rating)  5-2-2008    Views: 146   

User Comments

Add Comment
No comments have been posted.