This Blog is for all people working or related to the MSI and App-V. There are lots of issues we face in everyday work regarding the technology. The sole purpose of my blog is to help others with whatever I learn. All you people out there, please help by commenting, voting, propagating and sharing my blog with your friends and colleagues but with due credit and acknowledgement to the material posted here with my name and blog url as I still do hold the copyright of the posts here.
Thursday, February 14, 2013
VBScript to Delete Registrly key and all subkeys
This script has worked good for me and I would like to share with all.
Option Explicit
Dim intHive
Dim strComputer
Dim strKeyPath, objRegistry
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
'On Error Resume Next
strComputer = "."
intHive = HKEY_LOCAL_MACHINE
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ABC\XYZ"
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
DelSubkeys intHive, strKeypath
Set objRegistry = Nothing
Sub DelSubkeys(ByVal intRegistryHive, ByVal strRegistryKey)
Dim arrSubkeys
objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DelSubkeys intRegistryHive, strRegistryKey & "\" & strSubkey
Next
End If
objRegistry.DeleteKey intRegistryHive, strRegistryKey
End Sub
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment