Problems with RegRead 
Author Message
 Problems with RegRead

I'm having problems with the RegRead method of the Wscript.WShell object.
RegWrite seems to work ok, as does RegDelete, but any attempt to call
RegRead results in an error message to the effect that the file cannot be
located.

Does anyone have experience of a similar problem? This is under NT
Workstation SP3, Windows scripting host 1.0. I have admin rights and can
read the registry using regedit without problems.

Thanks in advance
Robert Burbidge

Remove the {NOSPAM} for return e-mail.



Fri, 18 May 2001 03:00:00 GMT  
 Problems with RegRead

Normally when you get this error, (90% of the time) the registry key that you are trying to read does not exists.
Check it out
http://cwashington.netreach.net

Win32 bit scripting. Everything you need to get up and running,
A script repository containing almost 100 sample scripts,
downloads, reference files, and technical support via an
online discussion forum.

(Pursuant to US Code, Title 47, Chapter 5, Subchapter II, 227, any and all
unsolicited commercial E-mail sent to this address is subject to a download
and archival fee in the amount of $1000 US.  E-mailing denotes acceptance of
these terms.)

I'm having problems with the RegRead method of the Wscript.WShell object.
RegWrite seems to work ok, as does RegDelete, but any attempt to call
RegRead results in an error message to the effect that the file cannot be
located.

Does anyone have experience of a similar problem? This is under NT
Workstation SP3, Windows scripting host 1.0. I have admin rights and can
read the registry using regedit without problems.

Thanks in advance
Robert Burbidge

Remove the {NOSPAM} for return e-mail.



Fri, 18 May 2001 03:00:00 GMT  
 Problems with RegRead
You'll have to post some sample code, RegRead works fine for me.

--
Tim Hill -- Windows NT MVP

(Pursuant to US Code, Title 47, Chapter 5, Subchapter II, 227, any and all
nonsolicited commercial E-mail sent to this address is subject to a download
and archival fee in the amount of $1000 US.  E-mailing denotes acceptance of
these terms.)


Quote:
>I'm having problems with the RegRead method of the Wscript.WShell object.
>RegWrite seems to work ok, as does RegDelete, but any attempt to call
>RegRead results in an error message to the effect that the file cannot be
>located.

>Does anyone have experience of a similar problem? This is under NT
>Workstation SP3, Windows scripting host 1.0. I have admin rights and can
>read the registry using regedit without problems.

>Thanks in advance
>Robert Burbidge

>Remove the {NOSPAM} for return e-mail.



Fri, 18 May 2001 03:00:00 GMT  
 Problems with RegRead

Quote:
>I'm having problems with the RegRead method of the Wscript.WShell object.
>RegWrite seems to work ok, as does RegDelete, but any attempt to call
>RegRead results in an error message to the effect that the file cannot be
>located.

...
You should test the existence of the key before trying to read it :

   Function ExistsKey (key)
      On Error Resume Next
      WshShell.RegRead (key)
      ExistsKey = Not CBool (Err)
      Err.Clear
   End Function ' ExistsKey



Sat, 19 May 2001 03:00:00 GMT  
 Problems with RegRead
OK. From memory,how about

Dim oShell, sVal

Set oShell = CreateObject("Wscript.Shell") ' or whatever, can't remember the
class name today

sVal = oShell.RegRead("HKEY_LOCAL_MACHINE\Software\ODBC")    ' Fails
sVal = oShell.RegRead("HKEY_LOCAL_MACHINE\Software\ODBC\")   ' Fails

I am trying to read ODBC info from the registry which is held under
HKLM\Software\ODBC\...

Have also tried HKLM for HKEY_LOCAL_MACHINE, no dice.

I want to enumerate the keys under "HKLM\Software\ODBC\ODBC.INI\ODBC Data
Sources" & read the values I find there.



Sat, 19 May 2001 03:00:00 GMT  
 Problems with RegRead
This is clear: if your try to read a registry entry which doesn't
exists, the RegRead-methods fails (unfortunately with a misleading
error text). You need to do the following:

In VBScript try:

On Error resume next
wsh.RegRead (.......)
If err <> 0 Then
 WScript.Echo "Entry doesn't exists"
 WScript.Quit()
End if

In JScript there is currently no Err-Object available (the Script engine
5.0 will have such a try ... Get feature). For my own purposes I wrote a
small ActiveX allowing me to use the WSHKeyExists-methode.

This ActiveX-Control and other techniques will be available to the public in
Jan 99 in:

MS Press "Inside the Windows Scripting Host"

Currently the book is just scheduled for MS Press Germany, but
I'm optimistic that there is enought response from Script-programmers
to convince MS Press USA to do the project also in English ;-)

Gnter Born
http://ourworld.compuserve.com/homepages/Guenter_Born

Gnter Born
http://ourworld.compuserve.com/homepages/Guenter_Born
Robert Burbidge <{NOSPAM}> schrieb in Nachricht

Quote:
>I'm having problems with the RegRead method of the Wscript.WShell object.
>RegWrite seems to work ok, as does RegDelete, but any attempt to call
>RegRead results in an error message to the effect that the file cannot be
>located.

>Does anyone have experience of a similar problem? This is under NT
>Workstation SP3, Windows scripting host 1.0. I have admin rights and can
>read the registry using regedit without problems.

>Thanks in advance
>Robert Burbidge

>Remove the {NOSPAM} for return e-mail.



Thu, 24 May 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Problems using RegRead Method

2. Problems w/ RegRead on REG_MULTI_SZ

3. Problem of regread method.

4. RegRead + try...catch problem

5. WshShell.RegRead of binary value problem

6. RegRead problem

7. regread - regwrite problem

8. RegRead error control problem

9. RegRead() limitations

10. RegRead

11. regread on a binary value

12. Regread

 

 
Powered by phpBB® Forum Software