help please: example of seeing of a registry key exists 
Author Message
 help please: example of seeing of a registry key exists

Hello...

I was trying to find an example of how to see if a registry key exists.
I image it assigning a value to a variable.  if the reg key exists, then the
variable
will have some length, and then assumed to be true, else no length: false.

javatrue =regtheregistry([HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java
Plug-in])
if len(javatrue)>0 then
    response.write "Yeah! We have Java Virtual Machine!!"
else
    response.write "No, you do NOT have Java Virtual Machine installed on
this computer."
end if

Is my logic sound?  Can anyone assist me please?  Thank you!

-Lucy



Mon, 14 Feb 2005 06:54:56 GMT  
 help please: example of seeing of a registry key exists
If your talking about using this from a webpage then the answer is how
secure could I be if I let you access the registry on my remote system?

Now as for the second use, you could create a script using Microsoft Windows
Script and use the RegRead Method.  For the documents check
http://www.microsoft.com/scripting .

PER THE DOCS:
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Val")   ' Read from value
"Val".
WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Key\") ' Read from key
"Key".

Bryan Martin


Quote:
> Hello...

> I was trying to find an example of how to see if a registry key exists.
> I image it assigning a value to a variable.  if the reg key exists, then
the
> variable
> will have some length, and then assumed to be true, else no length: false.

> javatrue =regtheregistry([HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java
> Plug-in])
> if len(javatrue)>0 then
>     response.write "Yeah! We have Java Virtual Machine!!"
> else
>     response.write "No, you do NOT have Java Virtual Machine installed on
> this computer."
> end if

> Is my logic sound?  Can anyone assist me please?  Thank you!

> -Lucy




Mon, 14 Feb 2005 09:53:34 GMT  
 help please: example of seeing of a registry key exists

Quote:

> Now as for the second use, you could create a script using Microsoft Windows
> Script and use the RegRead Method.  For the documents check
> http://www.microsoft.com/scripting .

> PER THE DOCS:
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Val")   ' Read from value
> "Val".
> WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Key\") ' Read from key
> "Key".

You will need to error handle this as well, the script will "crash" if you try
to read a non-existing value.

--
torgeir



Mon, 14 Feb 2005 10:22:42 GMT  
 help please: example of seeing of a registry key exists

Quote:

> WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Key\") ' Read from key

How can I get all "directories" resisting in that path/directory. I'm
talking about registry directories.

Alexander



Tue, 15 Feb 2005 07:04:34 GMT  
 help please: example of seeing of a registry key exists

Quote:

> WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Key\") ' Read from key

How can I recursivly travel through all "directories" which are stored
in that key to search for a special key/value pair?

Alexander



Tue, 15 Feb 2005 07:14:11 GMT  
 help please: example of seeing of a registry key exists

Quote:


> > WScript.Echo WshShell.RegRead("HKCU\ScriptEngine\Key\") ' Read from key

> How can I recursivly travel through all "directories" which are stored
> in that key to search for a special key/value pair?

Hi

You can use WMI for this...

EnumKey method
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/enumkey_method_in_...

EnumValues
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/enumvalues_method_...

Here is a VBScript/WMI example that walks a registry branch echoing all keys.
The third parameter (Boolean True/False) to the sub EnumRegistryKey will
determine if the sub is to stop at first level or traverse the complete tree:

Set oRegistry = GetObject("winmgmts:root/default:StdRegProv")
Const HKCR = &H80000000 'HKEY_CLASSES_ROOT
Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_DYN_DATA = &H80000006

EnumRegistryKey HKCU, _
   "Software\Microsoft\Windows\CurrentVersion\Group Policy", True

Sub EnumRegistryKey(hive, key, DeepTraversal)
  On Error Resume Next
  rc = oRegistry.EnumKey(hive, key, arSubKeys)
  For Each sKey In arSubKeys
    If Err Then
      Err.Clear
      Exit Sub
    End If
    WScript.Echo key & "\" & sKey
    If DeepTraversal Then
      EnumRegistryKey hive, key & "\" & sKey, True
    End If
  Next
End Sub

Some Script Center examples:

Enumerate Subkeys
http://www.microsoft.com/technet/scriptcenter/registry/scrreg09.asp

Enumerate Registry Values and Types
http://www.microsoft.com/technet/scriptcenter/registry/scrreg08.asp

--
torgeir



Tue, 15 Feb 2005 07:32:28 GMT  
 help please: example of seeing of a registry key exists

Quote:

> You can use WMI for this...

I don't develop this script for myself, someone else asked me to
create it for his own needs (small firm). They're using Win95 and
Win98. My question now: What are the requirements for WMI? Are they
installed on Win95/98 by default?

Alexander



Tue, 15 Feb 2005 13:12:39 GMT  
 help please: example of seeing of a registry key exists

Quote:

> > You can use WMI for this...

> What are the requirements for WMI?
> Are they installed on Win95/98 by default?

This technology is somehow new... needed Win2k or later. So it won't
work on Win95/98. Thanks anyway.

Alexander



Tue, 15 Feb 2005 13:30:16 GMT  
 help please: example of seeing of a registry key exists
Due to the limitations of Win9x when I have to do such a task I use
regedit /e <outputfile> <keyname>
to shoot the whole registry "tree" to a text file.  Then you can parse the
text file looking for whatever you need.
I usually put a 1/2 second or so wait in there after the export to make
certain the file gets committed to disk before starting the parse routine (I
have a lot of slower PCs to dela with!)
Hope that helps,


Quote:

> > You can use WMI for this...

> I don't develop this script for myself, someone else asked me to
> create it for his own needs (small firm). They're using Win95 and
> Win98. My question now: What are the requirements for WMI? Are they
> installed on Win95/98 by default?

> Alexander



Tue, 15 Feb 2005 23:13:39 GMT  
 help please: example of seeing of a registry key exists
Hi
I run W98SE, with IE5.5, and somewhere along the line I must have installed
WMI.  It works great on my system.  And while reading stuff in the online
documentation at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmis...
authority.asp, I see references to invoking it under W95 too.
-Paul Randall


Quote:

> > > You can use WMI for this...

> > What are the requirements for WMI?
> > Are they installed on Win95/98 by default?

> This technology is somehow new... needed Win2k or later. So it won't
> work on Win95/98. Thanks anyway.

> Alexander



Tue, 15 Feb 2005 23:59:09 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Getting SQL Server XML through ADO into Delphi

2. help please: example of seeing of a registry key exists

3. please Query the registry key existing?

4. Seeing if file exists. Please Help

5. Help: Renaming a existing registry key

6. Detecing if a registry key exists

7. Check if registry key exists

8. Doe a registry key exist?

9. Registry key exists?

10. How to determine if a Registry key exists?

11. check if a certain registry key exists or not

 

 
Powered by phpBB® Forum Software