Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking in key in registry windows 1

Status
Not open for further replies.

evilkalah

Technical User
Jul 30, 2003
11
BE
hello
i want to check if a value exist in the windows registry
i did it with regread both it gives an error that it doesn't exist

is there no way to check if it exist and then read it or .....


 
It woul'd help if you post your script code and the eorror message

Hope This Help
PH.
 
Hello evilkalah,

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
...

regards - tsuji
 
thx that was the problem.

my script is finisch now. it fixes the refresh rate bug of xp. it has standard 75khz now in stead of 60khz
 
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.

[tt]HKLM\System\CurrentControlSet\Control\Session Manager\Environment\OS[/tt]

Well, guess what, Windows XP/2000 contain &quot;Windows NT&quot;. 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 &quot;U&quot;) but not even that could I get.

I even tried these trees, but either one is used or the other, not both:

[tt]HKLM\Machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Version

HKLM\Machine\Software\Microsoft\Windows NT\CurrentVersion\Version

====================================================================[/tt]

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.

Thanks, dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top