MOTOBIT.COM - ASP upload, IIS utility ExistsKey Method of Key class

Method | Member of  RegEdit.Key | Changes | Purchase | Download

Description

Test of existence of key's subkey.

Syntax

vExistsKey = Key.ExistsKey (Name as String)
 

Where Type Optional Default Description
 Name  String     Name of the sub key. 

Returns

Boolean

Examples

Test of key's existence.

  'Get RegEdit.Server object
  Set S = CreateObject("RegEdit.Server")

  If Not S.GetKey("HKLM").ExistsKey("Software\MyApp") Then
    Wscript.Echo "MyApp is not installed."
  End If

Set TEMP and TMP Environment variables

  Option Explicit
  Dim S, Key, SubKey

  Dim TempFolder 

  If Wscript.Arguments.Count = 0 Then 
    Wscript.Echo "SetTemp - same temp folder for all users on this computer" & vbCrLf & _
     " cscript settemp.vbs tempfolder" & vbCrLf 
    Wscript.Quit
  End If

  'Read the temp folder argument
  TempFolder = Wscript.Arguments(0)


  'Get RegEdit.Server object
  Set S = CreateObject("RegEdit.Server")
  
  'Get a key
  Set Key = S.GetKey("HKU")

  For Each SubKey In Key.SubKeys
    Wscript.Echo SubKey.Name
    If SubKey.ExistsKey("Environment") Then
      Wscript.Echo SubKey.SubKeys("Environment").Values("TEMP")
      Wscript.Echo SubKey.SubKeys("Environment").Values("TMP")

      'Set TEMP and TMP registry Environment variables
      SubKey.SubKeys("Environment").Values("TEMP") = TempFolder
      SubKey.SubKeys("Environment").Values("TMP") = TempFolder
    End If                                                

  Next

  'Set system temp  
  Wscript.Echo S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TEMP")
  Wscript.Echo S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TMP")

  S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TEMP") = TempFolder 
  S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TMP") = TempFolder

Other links for ExistsKey

Methods of Key class

Close, CreateKey, Delete, ExistsKey, ExistsValue, Flush, numSubKeys, numValues, Save

Properties of Key class

Class, hKey, LastWriteTime, Name, SubKeys, Values

RegEdit.Key

One registry key.

RegEdit

Intuitive, easy to use COM interface to windows registry. Set of classes to read/enumerate/modify windows registry keys and values from ASP, VBS and T-SQL.

© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz