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