Did you find this useful?
Socialize it today.


Accessing the Local Registry Using VBScript

Friday, October 28, 2011

Accessing the local registry is quite easy using VBScript. Here are some examples on how to read, write, and delete information from the local registry.

RegRead Syntax

object.RegRead(strName)

dim objShell
set objShell=CreateObject("wscript.shell")
strProductName=objShell.RegRead("HKLM\Software\" &_
  "Microsoft\Windows NT\CurrentVersion\ProductName")
wscript.echo "Your computer is running " & strProductName


More information on the RegRead Method

http://msdn.microsoft.com/en-us/library/x05fawxd(VS.85).aspx

Writing back to the registry is just as easy.

RegWrite Syntax

object.RegWrite(strName, anyValue [,strType])

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\itgeared\Appname\",  &_
  "SomeString", "REG_SZ"


More information on the RegWrite Method
http://msdn.microsoft.com/en-us/library/yfdfhz1b(VS.85).aspx

If you need to delete a registry entry, follow this example.

RegDelete Syntax

object.RegDelete(strName)

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegDelete "HKCU\Software\itgeared\Appname\"


More information on the RegDelete Method
http://msdn.microsoft.com/en-us/library/293bt9hh(v=VS.85).aspx

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

Microsoft WSH and VBScript Programming for the Absolute Beginner Advanced VBScript for Microsoft Windows Administrators