What happens to my enumkey

G

Guest

I want to print a registry key but it doens't work as expected. How can i fix
this problem.?

thanks

'==========================
Const HKEY_LOCAL_MACHINE = &H80000002

spath="SOFTWARE\Microsoft\Windows\CurrentVersion\Setup"
showMe(spath)

'===================create function=============

Function showMe(Key)

aName="Installed"

Set oLoc = CreateObject("WbemScripting.SWbemLocator")
Set oSvc = oLoc.ConnectServer(null, "root/default")
Set oReg = oSvc.Get("StdRegProv")

Set oMethod = oReg.Methods_.Item("Enumkey")
Set oInParam = oMethod.InParameters.SpawnInstance_()
oInParam.hDefKey = HKEY_LOCAL_MACHINE
oInParam.sSubKeyName = Key
Set oOutParam = oReg.ExecMethod_(oMethod.Name, oInParam)

aNames = oOutParam.sNames

On Error Resume Next

For i = LBound(aNames) To UBound(aNames)
lrc= oReg.GetStringValue (HKEY_LOCAL_MACHINE, Key, aName, sValue)

If(lrc=0) Then
wscript.echo("Key: "&aNames(i)) ' doesn't work as expected
wscript.echo( aName &" : "& sValue)
wscript.echo("======================")
End If
showMe(Key&"\"&aNames(i))

Next

End Function
 
J

Jonathan Liu [MSFT]

What are you trying to accomplish in the script?

You are enumerating the keys under spath, however, you then want to get the
value for the keys? Are you trying to get the information of the values in
hte Keys?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top