Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


arrayList not populating correctly

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> arrayList not populating correctly
  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 >>
 arrayList not populating correctly - 4/17/2008 8:14:32 AM   
  blazted

 

Posts: 16
Score: 0
Joined: 2/6/2006
Status: offline
I am having a strange problem with a arrayList I am using. I am writing a script that will enumerate through the registry and check each key as it enumerates using regexp for a value based on a inout string. If it finds the value it then adds that key to the arrayList. This is menats to clean up a registry for bad software uninstalls. I have tow versions on this. The first version works correctly and adds all of the keys it searchs for to the arrayList. But it is snail slow. Here is the code for that. What i dod I placed a key in My HKLM\Software called Test-Delete and gave this key two sub keys called Test-Delete as well. This found each key and sub key and correcty added them to the arrayList but it is very very slow.


      

So I am trying to speed this up. So I simply added a second value to the Function so i change what HIVE to start the serach from. This sped it up to a workign speed but now it only gives me the root of where the Test-Delete is and does not give me the sub keys.


      

This is simply stopping once it gets to the first Instance of My search Expression and then the script stops. I added another Test-Delete key laster in the Hive but it simply quit after it hit the firts Test-Delete. Any ideas anyone?

Thanks
 
 
Post #: 1
 
 RE: arrayList not populating correctly - 4/17/2008 9:07:56 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Go through the recursion in your head. The first time that the function it is called it is called with LNGHKEY = "HKLM". So it goes through the If-Then construct and it sets hkroot to the constant HKEY_LOCAL_MACHINE. It uses this to make an array of all the top level subkeys. Now it calls itself again passing in hkroot as LNGHKEY. So now it is checking one level down and it goes through the if-then construct and none of the defined options matches LNGHKEY (remember it was passed in a value of HKEY_LOCAL_MACHINE). Since it doesn't see a match it defaults to HKCU. There is no such key in HKCU so voila it moves right along. The reason the second version runs so much faster is because it really only checks the top level keys.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blazted)
 
 
Post #: 2
 
 RE: arrayList not populating correctly - 4/17/2008 9:37:35 AM   
  blazted

 

Posts: 16
Score: 0
Joined: 2/6/2006
Status: offline
Thanks EB. I changed all my values to teh Full key so now it is always passing the full value so it wont default to the HKCU default in the statment. However in my debugger I still see it missing the keys and missing the serach.


      

So now I have it pass first the Full Root along with the Key into the Function. It then uses the If Else Statement and assigns the full value to the hkRoot. When the HkRoot uses recursion it now passes the full search Root value back to it. However It still is skipping. Where Am I mseeing up in this recursion?

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: arrayList not populating correctly - 4/21/2008 12:38:57 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
When you call the function for the subkeys, you are still calling it with hkroot which has a value of &H80000002. That value is nowhere in your if-then tests so it will still default to HKCU.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blazted)
 
 
Post #: 4
 
 
 
  

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 >> arrayList not populating correctly 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