Discussion Locked

WSHShell.Read and Registry

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have created the following script to read a value from a certain key from the Registry and disply it back.

Dim WSHShell, a
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Popup "Trying to read Paging File Size value'"
a = WSHShell.RegRead ("HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles")
WshShell.Popup "The current value is : " & a

However even though i have read the documentations, manuals, html pages and so on i have been unable to do it. I finally found the problem. The value i am trying to read is a REG_MULTI_SZ value. Thats why i get a type mismatch error. However the manuals say that RegRead does read this type of values. Anybody got an ideas how i can get round to it and read the value but most importantly display it?

1 reply

by gbworld

REG_MULTI_SZ is an array. As such, you need to loop through to find the values. Here is your script updated to get the correct answers:

Dim WSHShell, a, intLoop
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Popup "Trying to read Paging File Size value'"
a = WSHShell.RegRead ("HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles")
For intLoop = 0 to UBound(a)
WSHShell.Popup a(intLoop)
Next

Gregory A. Beamer
MCP: +I, SE, SD, DBA

This discussion is closed to new replies.