Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Read One Registry name/value from many subkeys.

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,51094
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Read One Registry name/value from many subkeys.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Read One Registry name/value from many subkeys. - 8/23/2007 5:59:07 AM   
  dahlgrenvb

 

Posts: 8
Score: 0
Joined: 3/5/2007
Status: offline
My terminology may not be correct. This is what I need to read.  The MANY USER NAMES would be read from about 3,000 registry username entries.  I need to monitor for changes in the strValueName value for all users under \MailUsers\.  I just can't find anything that tells me how to loop through all \MailUsers\ and get the strValueName value for each.

strKeyPath = "Software\Rockliffe\MailSite\MailUsers\MANY USER NAMES"
strValueName = "Personality"

I have no problem reading one value from one MailUser but just can't figure out the loop process for this one.  Any help would be appreciated. 

Verne Baxter (Dahlgren)
 
 
Post #: 1
 
 RE: Read One Registry name/value from many subkeys. - 8/23/2007 6:11:35 AM   
  Parabellum


Posts: 222
Score: 0
Joined: 11/12/2006
From: UK
Status: offline
not tested.. but try soething like this....


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

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

strKeyPath = "Software\Rockliffe\MailSite\MailUsers\MANY USER NAMES"

strValueName = "Personality"

oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
   oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subKey,strValueName,strValue

      wscript.echo strValue
Next

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

< Message edited by Parabellum -- 8/23/2007 6:13:47 AM >

(in reply to dahlgrenvb)
 
 
Post #: 2
 
 RE: Read One Registry name/value from many subkeys. - 8/25/2007 3:29:56 AM   
  dahlgrenvb

 

Posts: 8
Score: 0
Joined: 3/5/2007
Status: offline
I think I'm seeing the light at the end of the tunnel but I get the following error msg.  Mightn't I need to declare something? 

RegReadPerSig.vbs(25, 1) Microsoft VBScript runtime error: Object not a collection
Exit code: 0 , 0000h

(in reply to Parabellum)
 
 
Post #: 3
 
 RE: Read One Registry name/value from many subkeys. - 8/25/2007 3:34:51 AM   
  dahlgrenvb

 

Posts: 8
Score: 0
Joined: 3/5/2007
Status: offline
My apologies. The line number of the error included all the intro header stuff. Here's the line.

RegReadPerSig.vbs(12, 1) Microsoft VBScript runtime error: Object not a collection
Exit code: 0 , 0000h


12 For Each subkey In arrSubKeys 
13   oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subKey,strValueName,strValue
14     wscript.echo strValue

(in reply to dahlgrenvb)
 
 
Post #: 4
 
 RE: Read One Registry name/value from many subkeys. - 8/25/2007 5:27:37 PM   
  sheepz


Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
Copied from Parabellum, heres something that works for me:

const HKLM = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
oReg.enumValues HKLM, strKeyPath, arrSubkeys 'enum thru the values within strKeyPath
For Each strSubkey In arrSubkeys
   oReg.GetStringValue HKLM, strKeyPath, strSubKey
   If strSubkey <> "" Then 'check if empty
      MsgBox strSubkey
   End If
Next
MsgBox "complete"

depending on what you're trying to read, is it a Reg key(s) or Reg folder(s) within the registry.  example from the repository:  http://www.microsoft.com/technet/scriptcenter/scripts/os/registry/osrgvb10.mspx?mfr=true

< Message edited by sheepz -- 8/25/2007 5:30:32 PM >

(in reply to dahlgrenvb)
 
 
Post #: 5
 
 RE: Read One Registry name/value from many subkeys. - 8/27/2007 7:32:18 AM   
  dahlgrenvb

 

Posts: 8
Score: 0
Joined: 3/5/2007
Status: offline
All solutions thus far don't get me deep enough into the Registry. I'm sure it's my explanation of what is needed so I'll try again.  I'll keep it simple (for my sake).

Here are three users.  I can enumerate that deeply into the Registry no problem.  However, under each  users name there are subkeys and I need the value of one of those subkeys.

User Level
Software\Rockliffe\MailSite\MailUsers\joseph
Software\Rockliffe\MailSite\MailUsers\phil
Software\Rockliffe\MailSite\MailUsers\wally

SubKey Level
Software\Rockliffe\MailSite\MailUsers\joseph\personalitysignature
Software\Rockliffe\MailSite\MailUsers\phil\personalitysignature
Software\Rockliffe\MailSite\MailUsers\wally\personalitysignature

SubKeyValue Level
Software\Rockliffe\MailSite\MailUsers\joseph\personalitysignature\"This is Joseph's Signature"
Software\Rockliffe\MailSite\MailUsers\phil\personalitysignature\"This is Phil's Signature"
Software\Rockliffe\MailSite\MailUsers\wally\personalitysignature\"This is Wally's Signature"

So, I have to go through every one of the 16,000+ username registry entries for MailUsers and read the value of the string in the subkey personalitysignature.

Hope that makes more sense.  Actually i have managed to get to the point that I can read and list the SubKey Level as indicated above.  But I cannot get past that point.

Verne

(in reply to sheepz)
 
 
Post #: 6
 
 RE: Read One Registry name/value from many subkeys. - 8/27/2007 12:09:22 PM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Create a Sub/Function to help recurse through all sub folders...look at what you have and try to think of how you would accomplish that and put something together.  Look at the Frequently Asked Stuff post and you'll see an example of recursing through files and folders...though not the same...it is an example of recursion.

EnumKey will return an array of all sub keys under a particular key
EnumValues...well you're using it

These are pretty much all you need for what you have mentioned...just need to add "recursion"

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dahlgrenvb)
 
 
Post #: 7
 
 RE: Read One Registry name/value from many subkeys. - 8/27/2007 5:28:14 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
see if this helps


      

(in reply to dahlgrenvb)
 
 
Post #: 8
 
 RE: Read One Registry name/value from many subkeys. - 8/29/2007 4:45:59 AM   
  dahlgrenvb

 

Posts: 8
Score: 0
Joined: 3/5/2007
Status: offline
Okay, recursion it is.  I'll try to make it happen.  Thanks.

(in reply to dm_4ever)
 
 
Post #: 9
 
 RE: Read One Registry name/value from many subkeys. - 8/29/2007 4:47:04 AM   
  dahlgrenvb

 

Posts: 8
Score: 0
Joined: 3/5/2007
Status: offline
Thanks, that did help.  Armed with building a sub that recurses will finish it off.  Thanks to all that responded.

(in reply to gdewrance)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Read One Registry name/value from many subkeys. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts