Re: Please help: Getting REGISTRY info w/ StdRegProv

From: Michael Harris \(MVP\) ("Michael)
Date: 05/20/04


Date: Wed, 19 May 2004 19:39:28 -0700


> 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


Relevant Pages

  • Re: Group Policy modifying Registry Keys
    ... Try the REG ADD command. ... run it locally or apply the changes to either the login script or the ... Jeffrey Randow (Windows Networking & Smart Display MVP) ... >program that creates two registry keys on the user's local machine. ...
    (microsoft.public.windows.server.networking)
  • Re: Modify Registry on all SBS2003 clients
    ... but i have one question: Will the reg add comand work if the users ... logging on the client computer dont have administrative rights on the client ... registry setting to all workstations. ... You may copy above command into the login script file SBS_LOGIN_SCRIPT.bat ...
    (microsoft.public.windows.server.sbs)
  • Re: hi-jacked browser
    ... script --- so I've got a program called Script Sentry, ... Another thing they want to do is put entries in the ... reg where they start exe files or scripts on startup or reboot. ... Long story short --- yes, have firewalls, and AV stuff, but think, "OK, if ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • 802.1x settings - GPO? Script? - long, but I have a solution!
    ... I've been looking for a group policy or script to ... networks, no GPO that could deal with wired NICs, and contrary to many ... So started considering reg ... What is the GUID of the NIC in any given PC? ...
    (microsoft.public.win2000.security)
  • Re: Enabling RDP via a login script
    ... Probably the ones that haven't been rebooted since the script ... ' This part will enable RDP on the workstation ... Const HKLM = &H80000002 ... objReg.SetDWORDValue HKLM, strKeyPath, _ ...
    (microsoft.public.scripting.vbscript)