Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read datatype of registry

Status
Not open for further replies.

kaul1jos

Technical User
Jan 5, 2001
76
NL
Hi,

I'd like to read the registry and check what datatype DevicePath is.

I tried the standard scripting from Microsoft but then I got just the whole key CurrentVersion.

So I like to check if HKLM\Software\Microsoft\Windows\CurrentVersion\DevicePath is from the REG_EXPAND_SZ type. If this is not I would like to change it to this datatype.

Please help!!
 
Hello kaul1jos,

You can use wmi stdregprov to bind to the key containing the value. Then use .enumvalue method and read out the index of the valuename you are interested in from the out-array of valuename. From the index, you can read the value-type from the out-array of valuetype.
Code:
const HKLM=&h80000002
onst REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
const REG_MULTI_SZ = 7

skey="Software\Microsoft\Windows\CurrentVersion"
svname="DevicePath"
set regsvc=getobject("winmgmts:root\default:stdregprov")
iret=regsvc.enumvalue(HKLM,skey,avname,avtype)
if iret=0 then
    for i=0 to ubound(avname)
        if strcomp(avname(i),svname,1)=0 then
            wscript.echo "value name: " & skey & "\" & svname & vbcrlf & "value type: " & avtype(i)
            exit for
        end if
    next
end if
set regsvc=nothing
I list also the constants reflecting the value type (REG_SZ) etc. When you read avtype(i) the value corresponds to the commonly known type by these constant's names.

regards - tsuji

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top