All Forums >> [Scripting] >> WSH & Client Side VBScript >> Search Registry for value in unknown key Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
I'm very new at VBScript. After using goodle and this forum I've pieced together parts of different scripts. I'm at a dead end with my brain melting. I know this can't be a hard as i'm making it out to be. I'm tring to find if a registry exists to see if a machine has a CD-Burner in it. I found the registry key and all looked great execpt that the Drive is identified with a GUID. So from machine to machine my script is useless. The key is always located in "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CD Burning\Drives\??GUID identifing drive??\MaxCDWriteSpeed" Below the script would return Key exists with value of 48.
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\CD Burning\Drives\Volume{41b1a9eb-7f6a-11dd-b826-806d6172696f}" strValueName = "MaxCDWriteSpeed" objRegistry.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue If IsNull(strValue) Then Wscript.Echo "The registry key does not exist." Else Wscript.Echo "The registry key exists. ("& strValue &")" End If
I'm going to run this locally. If possible, and thanks for replying. I've also been tring to see if I could't search for whats below HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CD Burning\Drives\ and save that as a varaible.
That exactly what I was looking for. I'm glad you have the time to look at this. Now instead of just giving back echos. I'm having it write back to the registry. It writes the value fine for one instance like if null. But if I add it to the Else it gives me name redefined errors. And after reading google seems i'm tring to run the same code twice in the same namespace and need to use name ticks. But I can't get it to work right. I just left it as is so you could see what i'm tring to do. I thought if I named the value string differently it would work but nope.
Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
The reason for the error has to do with where you declare the variables (Dim)...normally you want to declare them before going into loops since you'll tend to see the error you were getting.