Delete registry key with VBS

Hi,

Just need a simple vbs script to delete registry key in windows

thanks
cooljam23Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LambersonSoftware EngineerCommented:
cooljam23,
From vb help files...

DeleteSetting appname, section[, key]

Bob
Mark_FreeSoftwareCommented:

i found this example:



Deleting a Registry Key

Uses WMI to delete the registry key HKLM\SOFTWARE\System Admin Scripting Guide.

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\System Admin Scripting Guide"
 
oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath


Deleting Registry Values

Uses WMI to delete all the registry values under HKLM\SOFTWARE\System Admin Scripting Guide.

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\System Admin Scripting Guide"
strDWORDValueName = "DWORD Value Name"
strExpandedStringValueName = "Expanded String Value Name"
strMultiStringValueName = "Multi String Value Name"
strStringValueName = "String Value Name"
 
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strDWORDValueName
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strExpandedStringValueName
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strMultiStringValueName
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName
vinnyd79Commented:

This will delete a key:

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\TestKey\"
Set WshShell = Nothing


This will delete a value:

Set WshShell = CreateObject("WScript.Shell")
WshShell.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyValue"
Set WshShell = Nothing

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.