Registry 
Author Message
 Registry

RegistryRegcreateKey will replace an existing key. Saves an unnessessary read if the existing value is of no further value.

  Hi

  I want to generate a key and a value in the registry. This is easy enough - but I want to check if the key exists before doing this (if it does I dont want to create it) - how can I do this?

  Kind regards

  Siv



Sat, 14 Sep 2002 03:00:00 GMT  
 Registry

RegistryTry something like this:

Sub CreateKey(RegKey,Value)
    Dim Shell
    Set Shell = CreateObject("Wscript.Shell")
    On Error Resume Next
    Err.Raise(Shell.RegRead(RegKey))
    If Len(Err.Description) = 41 Then
        Shell.RegWrite RegKey & "\",Value
    End If
End Sub


Hi
I want to generate a key and a value in the registry. This is easy
enough - but I want to check if the key exists before doing this (if
it does I dont want to create it) - how can I do this?
Kind regards
Siv



Sat, 14 Sep 2002 03:00:00 GMT  
 Registry

RegistryHere is a function written in VBScript that tests a key's existence.

Function KeyExists (key)
Dim key2
 On Error Resume Next
 key2 = WSHShell.RegRead (key)
 If err <> 0 Then
  KeyExists = False
 Else
  KeyExists = True
 End if
End Function

G. Born

Check out the WSH Bazaar at:

www.borncity.de


  Hi

  I want to generate a key and a value in the registry. This is easy enough - but I want to check if the key exists before doing this (if it does I dont want to create it) - how can I do this?

  Kind regards

  Siv



Sun, 15 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Read Registry Keys and Trees / API Call for Registry access

2. I have a problem : registry base and outlook signature

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

4. find the specify Root key and Sub key from the registry

5. Can WMI scripting be used to update registry?

6. VBScript and registry PagingFile Entry....

7. Registry from VBSCRIPT?

8. Registry

9. Reading registry settings using JScript

10. tighter security - capture a unique value from registry

11. How can I Read-Write the registry from a VBScript-Procedure of an outlook-form

12. How can I Read-Write remote registry

 

 
Powered by phpBB® Forum Software