Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted (edited)

I've been using a kix script to do this for ages (Delete registry keys with sub keys) that I couldn't do with a VB script then today I came accross a technet tutorial and I think I'm there. This might of already been posted but it didn't come up in a search.

 

Hey, Scripting Guy!: How Can I Delete a Key and its Subkeys from the Registry?

 

EDIT

 

I just need to work out how to point it to this key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder" then I'm there.

 

(Scratches head)

Edited by cookie_monster
  • Thanks 1
Posted

Right it's sorted now to put it into my real script :D

 

On Error Resume Next 

Const HKEY_CURRENT_USER = &H80000001 

strComputer = "."
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder" 

Set objRegistry = GetObject("winmgmts:\\" & _
   strComputer & "\root\default:StdRegProv") 

DeleteSubkeys HKEY_CURRENT_USER, strKeypath 

Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath) 
   objRegistry.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys 

   If IsArray(arrSubkeys) Then 
       For Each strSubkey In arrSubkeys 
           DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey 
       Next 
   End If 

   objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath 
End Sub

 

 

Some excellent extra info here on using WMI and VB to modify the registry.

 

http://blogs.technet.com/heyscriptingguy/archive/2004/10/27/how-can-i-change-the-screensaver-timeout-value.aspx

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...