Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

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

Reply
 
Old 04-15-2009   #1 (permalink)
Tony Logan


 
 

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

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 System SpecsSystem Spec
Old 04-16-2009   #2 (permalink)
Tony Logan


 
 

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

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:
Quote:

> 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 System SpecsSystem Spec
Old 04-16-2009   #3 (permalink)
\RemS


 
 

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

"Tony Logan" wrote:
Quote:

> 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/scr....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 System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Help and feedback with script searching the registry with regular expression VB Script
Registry Search Tool... Cleaning Up Vista Registry... Vista General
Wise Registry Cleaner vs AusLogics Registry Defrag vs CCLeaner? Vista performance & maintenance
Registry Semi-Disaster: I am an idiot - used 2 registry 'cleaners' Vista General
Still searching for way to get Vista search to work: Why doesn't FilterFilesWithUnknownExtensions registry key work in Vista? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46