Pages

Thursday, 21 June 2012

Check if Registry hive exists


Following script checks if HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft hive exists


const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."


Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")


strKeyPath = "SOFTWARE"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys


For Each subkey In arrSubKeys


    If subkey = "Microsoft" Then
   Exit For
     End If
Next


    MSGBOX subkey

No comments:

Post a Comment