Re: Please help: Getting REGISTRY info w/ StdRegProv
From: UNoHu (unohu.nospam_at_nospam.whoever.com)
Date: 05/20/04
- Next message: Len: "Connect to E-Mail Address in Database Field"
- Previous message: charney: "logon with another account"
- In reply to: Michael Harris \(MVP\): "Re: Please help: Getting REGISTRY info w/ StdRegProv"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 May 2004 09:38:02 -0500
EXCELLENT!! THANKS A MILLION MR. HARRIS!
It's even faster than before! Whoo hoo!
Thanks again,
UNoHu
Here is my resulting code:
'=== Start Code ===
sComputerName = "." ' use "." for local computer
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("WScript.Shell")
Dim DUMPFILE, EXPORTFILE, DUMPVIEW
EXPORTFILE = "C:\InstalledApps.txt"
Set DUMPFILE = oFSO.CreateTextFile(EXPORTFILE, True)
DUMPFILE.Write InstalledApplications(sComputerName)
WScript.Echo "DONE!"
Function InstalledApplications(node)
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& node & "/root/default:StdRegProv")
sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
oRegistry.EnumKey HKLM, sBaseKey, arySubKeys
For Each sKey in arySubKeys
oRegistry.EnumValues HKLM,sBaseKey & sKey,aryValueNames,aryValueTypes
If IsArray(aryValueNames) Then
InstalledApplications = InstalledApplications & "Key: " & sKey &
vbCrLf
For i=0 to UBound(aryValueNames)
sValueName = aryValueNames(i)
sValueType = aryValueTypes(i)
Select Case sValueType
Case REG_SZ
oRegistry.GetStringValue HKLM, sBaseKey & sKey,
sValueName, sValue
sValue = "REG_SZ: " & sValue
Case REG_EXPAND_SZ
oRegistry.GetExpandedStringValue HKLM, sBaseKey & sKey,
sValueName, sValue
sValue = "REG_EXPAND_SZ: " & sValue
Case REG_BINARY
oRegistry.GetBinaryValue HKLM, sBaseKey & sKey,
sValueName, sValue
sValue = "REG_BINARY: " & sValue
Case REG_DWORD
oRegistry.GetDWORDValue HKLM, sBaseKey & sKey,
sValueName, sValue
sValue = "REG_DWORD: " & sValue
Case REG_MULTI_SZ
oRegistry.GetMultiStringValue HKLM, sBaseKey & sKey,
sValueName, sValue
sValue = "REG_MULTI_SZ: " & sValue
End Select
InstalledApplications = InstalledApplications & sValueName & ": " &
sValue & vbCrLf
Next
End If
Next
End Function
"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:uXSu1OhPEHA.620@TK2MSFTNGP10.phx.gbl...
> > I'm building a script for software inventory purposes. I've use
> > Torgeir's script to get "DisplayName"s from the registry with no
> > problems and needed to get more info so, after a lot of digging, the
> > resulting script is below. The output is confusing me. I'm thinking
> > that 'aryValueNames' and 'aryValueTypes' are either not being created
> > properly or not being read properly (out of sync). I'm not exactly
> > sure what is going on as I am fairly new to vbscript and wmi. Below
> > the script is a small portion of the results.
>
>
> Here's a generic working example that I posted to the NGs back in May
2002.
>
> I'll leave it to you to determine how what you are doing is different from
> the example ;-)...
>
>
> const HKCR = &H80000000 'HKEY CLASSES ROOT
> const HKCU = &H80000001 'HKEY CURRENT USER
> const HKLM = &H80000002 'HKEY LOCAL MACHINE
>
> set reg = getobject("winmgmts:root\default:StdRegProv")
> hive = HKLM
> 'key = "software\microsoft\windows script host\settings"
> key = "software\microsoft\windows nt\currentversion"
>
> rc = reg.enumvalues(hive,key,valuenames,valuetypes)
>
> for n = 0 to ubound(valuenames)
> vname = valuenames(n)
> vtype = valuetypes(n)
> select case vtype
> case 1 'reg sz
> vtype = "[reg_sz]"
> reg.getstringvalue hive,key,vname,vvalue
> case 2 'reg expand sz
> vtype = "[reg_expand_sz]"
> reg.getexpandedstringvalue hive,key,vname,vvalue
> case 3 'reg binary
> vtype = "[reg_binary]"
> reg.getbinaryvalue hive,key,vname,vvalue
> for x = 0 to ubound(vvalue)
> vvalue(x) = "0x" & right("0" & hex(vvalue(x)),2)
> next
> case 4 'reg dword
> vtype = "[reg_dword]"
> reg.getdwordvalue hive,key,vname,vvalue
> case 7 'reg multi sz
> vtype = "[reg_multi_sz]"
> reg.getmultistringvalue hive,key,vname,vvalue
> case else 'unsupported type
> vtype = "[unsupported type]"
> vvalue = ""
> end select
> if isarray(vvalue) then
> wscript.echo vname,vtype,"=",join(vvalue,"; ")
> else
> wscript.echo vname,vtype,"=",vvalue
> end if
> next
>
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
> Sammamish WA US
>
- Next message: Len: "Connect to E-Mail Address in Database Field"
- Previous message: charney: "logon with another account"
- In reply to: Michael Harris \(MVP\): "Re: Please help: Getting REGISTRY info w/ StdRegProv"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|