Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Problem understanding enumkey method always getting "Object Not a Collection"

$
0
0

Hi Guys.

I usually find lots of information to help within the existing posts but this one is eluding me :(

I'm having a problem with this code.

when i try to lists the contents for akeys (list of keys in a certain registry path) i get a error " Object not a collection"

( I know enumkey can return a 0 if its successful but I'm not sure how to check it (if (Set oOutParams = oReg.ExecMethod_("Enumkey", oInParams, , oCtx) ) = 0 does not see to work :) )

Also if i use the simplified method of "reg.enumValues( HKLM, keyPath, valueNames, types )" it works, however my code is in 32bit format and some paths are comming up empty on 64bit machines...

Dim oCtx, oLocator, oReg, oInParams, oOutParams
Dim kroot, kpath, arch

kroot = &H80000002
kpath = "SOFTWARE\Microsoft\NetSh"
arch = 64

Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", arch

Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

set oInParams = oReg.Methods_("Enumkey").InParameters
oInParams.hDefKey = kroot
oInParams.sSubKeyName = kpath
  
Set oOutParams = oReg.ExecMethod_("Enumkey", oInParams, , oCtx) 
 
EnumKey = oOutParams.snames

For Each sKey In EnumKey
 WScript.Echo sKey
Next

Any Help would be appreciated!

thanks!


Anthony Cartier-Info


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>