How to read, write and delete registry entries

this information was obtained from: http://support.microsoft.com/kb/244675/EN-US/

WSHShell = CreateObject("WScript.Shell")

*!* Create Registry Keys
WSHShell.Popup( "Create key HKCUMyRegKey with value 'Top level key'")
WSHShell.RegWrite( "HKCUMyRegKey", "Top level key")

WSHShell.Popup( "Create key HKCUMyRegKeyEntry with value 'Second level key'")
WSHShell.RegWrite( "HKCUMyRegKeyEntry", "Second level key")

WSHShell.Popup( "Set value HKCUMyRegKeyValue to REG_SZ 1")
WSHShell.RegWrite ("HKCUMyRegKeyValue", 1)

WSHShell.Popup( "Set value HKCUMyRegKeyEntry to REG_DWORD 2")
WSHShell.RegWrite( "HKCUMyRegKeyEntry", 2, "REG_DWORD")

WSHShell.Popup( "Set value HKCUMyRegKeyEntryValue1 to REG_BINARY 3")
WSHShell.RegWrite( "HKCUMyRegKeyEntryValue1", 3, "REG_BINARY")

*!* Read Registry Keys
lcValue1 = WSHShell.RegRead("HKCUMyRegKey")
WSHShell.Popup("Value of HKCUMyRegKey: " + lcValue1)

lcValue2 = WSHShell.RegRead("HKCUMyRegKeyEntry")
WSHShell.Popup("Value of HKCUMyRegKeyEntry: " + lcValue2)

lcValue3 = WSHShell.RegRead("HKCUMyRegKeyValue")
WSHShell.Popup("Value of HKCUMyRegKeyValue: " + lcValue3)

lnValue1 = WSHShell.RegRead("HKCUMyRegKeyEntry")
WSHShell.Popup("Value of HKCUMyRegKeyEntry: " + ALLTRIM(STR(lnValue1)))

lnValue3 = WSHShell.RegRead("HKCUMyRegKeyEntryValue1")
WSHShell.Popup("Value of HKCUMyRegKeyEntryValue1: " + ALLTRIM(STR(lnValue3(1))))

*!* Delete Registry Keys
WSHShell.Popup( "Delete value HKCUMyRegKeyEntryValue1")
WSHShell.RegDelete( "HKCUMyRegKeyEntryValue1")

WSHShell.Popup ("Delete key HKCUMyRegKeyEntry")
WSHShell.RegDelete( "HKCUMyRegKeyEntry")

WSHShell.Popup ("Delete key HKCUMyRegKey")
WSHShell.RegDelete( "HKCUMyRegKey")

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.