Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help please: example of seeing of a registry key exists

48 views
Skip to first unread message

dhi

unread,
Aug 28, 2002, 6:54:56 PM8/28/02
to
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
lu...@dhimaging.com.au


Bryan Martin

unread,
Aug 28, 2002, 9:53:34 PM8/28/02
to
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
Sp...@ahwayside.com

"dhi" <nos...@dhimaging.com.au> wrote in message
news:4xcb9.20585$MC2....@news-server.bigpond.net.au...

Torgeir Bakken

unread,
Aug 28, 2002, 10:22:42 PM8/28/02
to
Bryan Martin wrote:

> 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


Alexander Schuch

unread,
Aug 29, 2002, 7:04:34 PM8/29/02
to
Bryan Martin wrote:

> 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

Alexander Schuch

unread,
Aug 29, 2002, 7:14:11 PM8/29/02
to
Bryan Martin wrote:

> 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

Torgeir Bakken

unread,
Aug 29, 2002, 7:32:28 PM8/29/02
to
Alexander Schuch wrote:

Hi

You can use WMI for this...

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

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

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


Alexander Schuch

unread,
Aug 30, 2002, 1:12:39 AM8/30/02
to
Torgeir Bakken wrote:

> 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

Alexander Schuch

unread,
Aug 30, 2002, 1:30:16 AM8/30/02
to
Alexander Schuch wrote:

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

Ned Flanders

unread,
Aug 30, 2002, 11:13:39 AM8/30/02
to
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,

"Alexander Schuch" <alex....@gmx.de> wrote in message
news:3d6efe50....@news.cis.dfn.de...

Paul Randall

unread,
Aug 30, 2002, 11:59:09 AM8/30/02
to
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/wmisdk/wmi/
authority.asp, I see references to invoking it under W95 too.
-Paul Randall

"Alexander Schuch" <alex....@gmx.de> wrote in message

news:3d6f0270....@news.cis.dfn.de...

0 new messages