reading registry keys 
Author Message
 reading registry keys

This works fine on an win98 box, but fails on NT4 or 2000. Any help would be
appreciated.

Set WshShell = CreateObject("WScript.Shell")
' On Error Resume Next
WshShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\")
If err.number <> 0 Then
  MsgBox "Key not found."
  Set Shell = WScript.CreateObject("WScript.Shell")
  Shell.run "\\Server\TEST$\test.bat"
Else
  MsgBox "Key exists."
End If

The error is:

Unable to open Registry Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\" for
Reading

Thanks,

Billy Graham



Mon, 16 Sep 2002 03:00:00 GMT  
 reading registry keys
This is possibly due to a bug - does the user on the NT4/Win2K box have
administrative privledges - or, more specifically, write access to that key?
The code that reads values from the registry attempts to open them with
write permissions, and fails when it can't, regardless of whether you are
actually trying to write to the registry or not.

A possible workaround - there's a control called regobj.dll that may take
care of the problem. Borrowing some text from one of Michael Harris' posts:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
You can enumerate keys with RegObj.dll which you can get at

Win32 Scripting [Clarence Washington]
http://cwashington.netreach.net
http://cwashington.netreach.net/script_repository/repository.asp
http://cwashington.netreach.net/script_repository/query.asp
http://cwashington.netreach.net/main_site/downloads
http://cwashington.netreach.net/script_repository/faqs.asp?topic=wmifaq
http://cwashington.netreach.net/script_repository/faqs.asp?topic=adsifaq

You can also search the ng posts at deja.com for posts by Walter Zackery who
has posted a regedit
based alternative several times...  (Walter, ya' still got that one?)

--
Michael Harris
MVP Scripting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Mike Whalen
Windows Script Dev


Quote:
> This works fine on an win98 box, but fails on NT4 or 2000. Any help would
be
> appreciated.

> Set WshShell = CreateObject("WScript.Shell")
> ' On Error Resume Next
> WshShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\")
> If err.number <> 0 Then
>   MsgBox "Key not found."
>   Set Shell = WScript.CreateObject("WScript.Shell")
>   Shell.run "\\Server\TEST$\test.bat"
> Else
>   MsgBox "Key exists."
> End If

> The error is:

> Unable to open Registry Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\"
for
> Reading

> Thanks,

> Billy Graham




Mon, 16 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Read Registry Keys and Trees / API Call for Registry access

2. Read Registry key via JScript

3. Reading Registry keys??

4. Reading registry keys in vbscript from ASP page

5. How to read registry key containing many string values

6. Reading Registry Key

7. Reading registry key

8. Problem reading registry key

9. Reading registry keys

10. Can't read Registry key (but can read value name)?

11. Reading Registry keys via JScript/JavaScript (is it possible?)

12. Reading registry keys and displaying them in a select box.

 

 
Powered by phpBB® Forum Software