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
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