Page 1 of 1 1
Topic Options
#120454 - 2004-06-01 10:54 PM How do I get reg SubKeyNames & values from SubKey?
chmod Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
I can get key values but do not know how to get a list of SubKeyNames then take those SubKeyNames and pass that to get a key value from each SubKey. I have read most of the UDF's/Posts and can not find this info. How would I get SubKeyNames and values from those keys? Specifically from HKCU\Network - I want to list all the drives listed (i.e. SubKeys of \Network) and the UNC path, "RemotePath" value, listed in each SubKey. How can I do this?

Top
#120455 - 2004-06-01 11:07 PM Re: How do I get reg SubKeyNames & values from SubKey?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
EnumValue() is used to well... enumerate the values, so EnumKey() would enumerate the keys. Am I missing something?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120456 - 2004-06-01 11:11 PM Re: How do I get reg SubKeyNames & values from SubKey?
chmod Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
I tried fEnumKey() and could not get it to work. It wont list the subkeys for HKCU\network, weird.
Top
#120457 - 2004-06-01 11:16 PM Re: How do I get reg SubKeyNames & values from SubKey?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I am not talking about the UDF but rather the built-in KiX EnumKey(). Are you sure you have your terminology right? In RegEdit, the 'keys' are in the left pane while the 'values' are in the right pane.

My HKEY_CURRENT_USER\Network key is totally empty so cannot see what you are trying to see.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120458 - 2004-06-01 11:19 PM Re: How do I get reg SubKeyNames & values from SubKey?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
here is something for you to look at..

Code:
$index = 0

While @Error = 0
$key = EnumKey("HKCU\Network",$index)
If $key
$value = ReadValue ("HKCU\network\"+$key,"RemotePath")
? $key
? "Path : "+$value
?
Endif
$index = $index+1
Loop

get $



If you tell us what it is exactly that you're trying to accomplish we could probably help you more extensively.

Oh and Les...The HKCU\Network seems to just hold persistent drive mapping information (on XP Pro atleast).

Top
#120459 - 2004-06-01 11:19 PM Re: How do I get reg SubKeyNames & values from SubKey?
chmod Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
If you map a network share and make it persistant, a subkey will show up under \Network for that drive letter you just mapped. i.e.
-Network
F <-- Subkey (folders, with values in them)
G
H

Top
#120460 - 2004-06-01 11:25 PM Re: How do I get reg SubKeyNames & values from SubKey?
chmod Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
Quote:

here is something for you to look at..

Code:
$index = 0
While @Error = 0
$key = EnumKey("HKCU\Network",$index)
If $key
$value = ReadValue ("HKCU\network\"+$key,"RemotePath")
? $key
? "Path : "+$value
?
Endif
$index = $index+1
Loop

get $







Nice! That's exactly what I was trying to do CitrixMan! LOL That's awesome! Thank you guys, you are great!

Top
#120461 - 2004-06-02 12:07 AM Re: How do I get reg SubKeyNames & values from SubKey?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shane,
Your code assumes @Error not to be thrown from a prior function. Better to clear it before entering your loop just to be sure. A lesson may be gleened from:
Structured EnumKey Loop /w a single EnumKey
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120462 - 2004-06-02 01:00 AM Re: How do I get reg SubKeyNames & values from SubKey?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Good point...I like the following one the best then...

Code:
$index = Execute("Exit 0")
While @Error <> 259
$key = EnumKey("HKCU\Network",$index)
If $key
$value = ReadValue ("HKCU\network\"+$key,"RemotePath")
? $key
? "Path : "+$value
?
Endif
$index = $index+1
Loop

get $


Top
#120463 - 2004-06-02 02:05 AM Re: How do I get reg SubKeyNames & values from SubKey?
chmod Offline
Fresh Scripter

Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
What does the Get $ on the last line do?
Top
#120464 - 2004-06-02 02:18 AM Re: How do I get reg SubKeyNames & values from SubKey?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Borrowing from the manual...
Quote:

Accepts a single character from the keyboard and stores the character in a variable


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120465 - 2004-06-02 02:26 AM Re: How do I get reg SubKeyNames & values from SubKey?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
It just causes the script to pause until a key is hit.
Top
#120466 - 2004-06-02 05:17 AM Re: How do I get reg SubKeyNames & values from SubKey?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also ArrayEnumKey() and ArrayEnumValue() in the UDF Library.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.069 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org