Thursday, May 1, 2014

Removing 64 bit registry key using Wise Script




On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strKeyPath = "Software\Macromedia
strKeypath1 = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
strValueName = "CurrentVersion"


Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", 64
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objRegistry = objServices.Get("StdRegProv")


objRegistry.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath1, strValueName  
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath 

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

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

    objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath 
End Sub

No comments:

Post a Comment