Jump to content

Best way to search for a reg key?


ken82m
 Share

Recommended Posts

Okay while I have done similiar things before it was a pain and didn't seem too efficient.

I'm hoping somebody has a better way.

Key

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<ProfileName>\13dbb0c8aa05101a9bb000aa002fc45a

Value

00036601 (REG_BINARY)

I am writing a script to manipulate an outlook configuration. The mystery part is the "ProfileName" key. I have no way of knowing for sure what that profile name is and their could be multiple profile keys.

So what I'm looking for is a simple way to pull a list of keys directly underneath "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" That way I can do a simple RegExists and change whatever profiles need updating.

Thanks,

Kenny

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

Okay while I have done similiar things before it was a pain and didn't seem too efficient.

I'm hoping somebody has a better way.

Key

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<ProfileName>\13dbb0c8aa05101a9bb000aa002fc45a

Value

00036601 (REG_BINARY)

I am writing a script to manipulate an outlook configuration. The mystery part is the "ProfileName" key. I have no way of knowing for sure what that profile name is and their could be multiple profile keys.

So what I'm looking for is a simple way to pull a list of keys directly underneath "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" That way I can do a simple RegExists and change whatever profiles need updating.

Thanks,

Kenny

Since you know exactly where to look and don't need to do a recursive search, just enumerate the keys that are there with RegEnumKey(). The only problem there is it will not return a complete list, you have to enumerate in a loop:

#include <array.au3>

$sKeyRoot = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$sKeyList = ""
For $i = 1 To 1000
    $sKey = RegEnumKey($sKeyRoot, $i)
    If @error Then ExitLoop
    $sKeyList &= Chr(1) & $sKey
Next
$avKeyList = StringSplit(StringTrimLeft($sKeyList, 1), Chr(1))
_ArrayDisplay($avKeyList, "Debug: $avKeyList")

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Okay while I have done similiar things before it was a pain and didn't seem too efficient.

I'm hoping somebody has a better way.

Key

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<ProfileName>\13dbb0c8aa05101a9bb000aa002fc45a

Value

00036601 (REG_BINARY)

I am writing a script to manipulate an outlook configuration. The mystery part is the "ProfileName" key. I have no way of knowing for sure what that profile name is and their could be multiple profile keys.

So what I'm looking for is a simple way to pull a list of keys directly underneath "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" That way I can do a simple RegExists and change whatever profiles need updating.

Thanks,

Kenny

RegEnumKey() would likely be your best bet.

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Damn I feel stupid lol - was sitting right in the help file. Just haven't had time to read up on all the commands since the last time I did this.

Thanks guys.

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

You might be able to use:

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile

To get the value you need.

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

You might be able to use:

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile

To get the value you need.

One catch I ran into there was that the profile itself has a lot of random subkeys under it as well. Then you have to search under one or more of the subkeys to find a ValueName that matched.

Here's a quick and dirty check for it on a "multiple-profile" system (I capped the subkeys at 100, you can raise or lower based on the expected number of profiles on the box):

CODE

$sRootKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

$sValueCheck = "00036601"

For $i = 1 To 100

$sProfileName = RegEnumKey($sRootKey, $i)

If @error <> 0 Then ExitLoop

MsgBox(0, "Profile Name", $sProfileName)

For $key = 1 To 100

$sProfileKey = RegEnumKey($sRootKey & $sProfileName, $key)

If @error <> 0 Then ExitLoop

$check = RegRead($sRootKey & $sProfileName & "\" & $sProfileKey, $sValueCheck)

If Not @error Then

MsgBox(64, "ValueName found", "A matching ValueName " & "(" & $sValueCheck & ")" & " found under:" & @LF & $sProfileName &"\" &$sProfileKey)

EndIf

Next

Next

Edit: wording

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Here's what I came up with based on what you guys gave me, works Perfectly. Thanks alot for the help.

Believe or not Monamo those subkeys aren't random (I know I never would have guessed either)

The subkey 13dbb0c8aa05101a9bb000aa002fc45a relates to exchange settings.

And the binary value 00036601 contains the connection parameters or mode (ie., cached mode, offline mode etc.)

The first two numbers control what I want. 04 would seem to be direct connect like outlook 2000 or XP would do and 84 would seem to be cached mode. Or at least it did in all my tests.

We recently went through a mail migration and most of the other devisions laughed at my custom transform for Outlook.

Except now I'm one of a few divisions in cached mode and they all need to be lol. Which as you can see is a little more complex..

Anyway thanks again guys. As always the members of this forum kick a**

Happy Holidays

-Kenny

#include <array.au3>
#include <String.au3>
$sKeyRoot = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$sKeyList = ""
$i = 1
$Replaced = 0

Do
$sKey = RegEnumKey($sKeyRoot, $i)
If @error <> 0 Then ExitLoop
$i = $i + 1
$sKeyList &= Chr(1) & $sKey
$avKeyList = StringSplit(StringTrimLeft($sKeyList, 1), Chr(1))
$RegVal = RegRead($sKeyRoot & "\" & $avKeyList[1] & "\13dbb0c8aa05101a9bb000aa002fc45a", "00036601")
$OutlookMode = StringLeft($RegVal, 2)
If $OutlookMode = 04 Then
$RegVal = StringTrimLeft($RegVal, 2)
$RegVal = _StringInsert($RegVal, 84, 0)
RegWrite($sKeyRoot & "\" & $avKeyList[1] & "\13dbb0c8aa05101a9bb000aa002fc45a", "00036601", "REG_BINARY", $RegVal)
If RegRead($sKeyRoot & "\" & $avKeyList[1] & "\13dbb0c8aa05101a9bb000aa002fc45a", "00036601") = $RegVal Then $Replaced =   $Replaced + 1
EndIf
EndIf
Until 1 = 2

If $Replaced = 0 Then
MsgBox(4096, "Outlook Update", "No profiles requiring update could be found")
Else
MsgBox(4096, "Outlook Update", "Number of profiles that would have been updated:  " & $Replaced)
EndIf

Exit
Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...