Apart from using a wrong syntax for the key, with WshShell RegRead method, you have to make you own little error handling in case the key does not exist. Something like ...
On Error Resume Next
...
WshShell.RegRead ...
If err.number <>0 Then
...
err.clear
End If
...
I searched for matches using WSH's REGREAD and READ / READING REGISTRY KEY / KEYS and this is the only thread I found which answered my current problem.
I am trying to populate the network logon username to older computers. I have an older DOS program to maintain that can read the DOS SET variables but is blind to the Windows environment. Windows XP and 2000 have a USERNAME variable available in the Command Prompt (DOS) windows, but not Windows Me, 98se or 98. So I have to create my own variable. So I decided to test first for the registry key below whether it is an NT-class computer.
Well, guess what, Windows XP/2000 contain "Windows NT". But in Windows Me/98/98se it doesn't exist and it creates error 80070002. At first I though I should at least get a data type back as Undefined (vartype of 8 is "U" but not even that could I get.
I even tried these trees, but either one is used or the other, not both:
So until I locate a key which both Windows families share and which tell which family it is, I'll have to use the above suggestion to handle the error: test for an error and reset the error handler using error.clear as appropriate.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.