• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

searching registry: know the value, don't know the key

T

Tony Logan

#1
I'm stumped. I'm trying to figure out how to edit the date for a registry
value when I don't know the exact key location that value appears under.

I know the value I'm interested in will appear somewhere beneath this key
(or one of this keys sub-keys):
SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}

I know the name of the value is "WakeUpModeCap".

I also know the data for this value should be "3", but could also be other
numeric values.

Can anyone help get me started? Thanks.
 

My Computer

T

Tony Logan

#2
Got part of the way to an answer, but I'm going to repost, since my issue is
now in a different topic. My partial solution is that since I know the
approximate place in the registry where I need to make a possible change, I'm
exporting that key and all its contents, then editing the .reg file (since
it's a text file and since I know how to edit a text file), then importing
that key. Will post a separate entry about a better wat to edit the .reg file
than how I'm doing it now.

"Tony Logan" wrote:

> I'm stumped. I'm trying to figure out how to edit the date for a registry
> value when I don't know the exact key location that value appears under.
>
> I know the value I'm interested in will appear somewhere beneath this key
> (or one of this keys sub-keys):
> SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}
>
> I know the name of the value is "WakeUpModeCap".
>
> I also know the data for this value should be "3", but could also be other
> numeric values.
>
> Can anyone help get me started? Thanks.
>
 

My Computer

R

\RemS

#3
"Tony Logan" wrote:

> I'm stumped. I'm trying to figure out how to edit the date for a registry
> value when I don't know the exact key location that value appears under.
>
> I know the value I'm interested in will appear somewhere beneath this key
> (or one of this keys sub-keys):
> SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}
>
> I know the name of the value is "WakeUpModeCap".
>
> I also know the data for this value should be "3", but could also be other
> numeric values.
>
> Can anyone help get me started? Thanks.
Here is a start:
http://www.microsoft.com/technet/scriptcenter/guide/sas_reg_famr.mspx?mfr=true


Sample:
'----------------------------------------------------------------------------

Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7

Dim objReg, strRootPath, RegKey, ValueName, DataType

RegEntryName = "WakeUpModeCap"
strKeyPath = "SYSTEM\CurrentControlSet\Control\" _
& "Class\{4D36E972-E325-11CE-BFC1-08002bE10318}"

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

SearchInKey HKEY_LOCAL_MACHINE, strKeyPath 'recursively subkeys too

Wscript.echo "Done" : Wscript.quit

Sub SearchInKey(ByVal Hive, ByVal strKeyPath)
ItemsInKey Hive, strKeyPath

objReg.EnumKey Hive, strKeyPath, arrSubKeys
If TypeName(arrSubKeys) <> "Null" Then
For Each subkey In arrSubKeys
SearchInKey Hive, strKeyPath & "\" & subkey
Next
End If
End Sub

Function ItemsInKey(ByVal Hive, ByVal strKeyPath)
Dim strOUT, DataType
Select Case Hive
Case -2147483646 strRootPath = "HKLM\"
Case -2147483645 strRootPath = "HKCU\"
Case Else strRootPath = "<...>\"
End Select

objReg.EnumValues Hive, strKeyPath, arrValueNames, arrValueTypes
If TypeName(arrValueNames) <> "Null" Then
For i = 0 To UBound(arrValueNames)
ValueName = arrValueNames(i)
RegKey = strKeyPath
strOUT = SearchForItem(RegEntryName)
If Len(strOUT) >1 Then

Select Case arrValueTypes(i)

Case REG_SZ
DataType = "REG_SZ: " ' (String)
objReg.GetStringValue Hive, _
strKeyPath, ValueName, strValue
wscript.echo strOUT & DataType, strValue

Case REG_EXPAND_SZ
DataType = "REG_EXPAND_SZ: " ' (Expanded String)
objReg.GetExpandedStringValue Hive, _
strKeyPath, ValueName, estrValue
wscript.echo strOUT & DataType, estrValue

Case REG_BINARY
DataType = "REG_BINARY" ' (Binary)
objReg.GetBinaryValue Hive, _
strKeyPath, ValueName,arrValue
If TypeName(arrValue) <> "Null" Then
For k = 0 to UBound(arrValue) -1 step 2
strChar = chr(arrValue(k))
sValue = sValue & strChar
Next
End If
wscript.echo strOUT & DataType, sValue

Case REG_DWORD
DataType = "REG_DWORD: " ' (DWORD)
objReg.GetDWORDValue Hive, _
strKeyPath, ValueName,dwValue
wscript.echo strOUT & DataType, dwValue

Case REG_MULTI_SZ
DataType = "REG_MULTI_SZ: " ' (Multi String)
objReg.GetMultiStringValue Hive, _
strKeyPath, ValueName,arrValues
If TypeName(arrValues) <> "Null" Then
For Each strValue in arrValues
sValue = sValue & strValue & vbNewLine
Next
End If
wscript.echo strOUT & DataType, sValue

End Select
End If
Next
End If
End Function

Function SearchForItem(RegEntryName)
If lCase(ValueName) = lCase(RegEntryName) Then
SearchForItem = strRootPath & RegKey & "\" _
& vbNewLine & vbNewLine & ValueName & vbNewLine
Else
SearchForItem = Empty
End If
End Function

'----------------------------------------------------------------------------

\Rems
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)