I've written some scripts for the registry, but I want to know how to get a
return value if a key exsists. It doesn't appear to allow me to return a
number if the key exisits or not.
Example:
This script was taken from the Script Center
(http://www.microsoft.com/technet/community/scriptcenter/registry/scrreg08.m
spx)
Script Start
------------
const HKEY_LOCAL_MACHINE = &H80000002
const REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
const REG_MULTI_SZ = 7
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Test Application"
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
WScript.Echo Err.number, Err.Description
For i=0 To UBound(arrValueNames)
StdOut.WriteLine "Value Name: " & arrValueNames(i)
Select Case arrValueTypes(i)
Case REG_SZ
StdOut.WriteLine "Data Type: String"
StdOut.WriteBlankLines(1)
Case REG_EXPAND_SZ
StdOut.WriteLine "Data Type: Expanded String"
StdOut.WriteBlankLines(1)
Case REG_BINARY
StdOut.WriteLine "Data Type: Binary"
StdOut.WriteBlankLines(1)
Case REG_DWORD
StdOut.WriteLine "Data Type: DWORD"
StdOut.WriteBlankLines(1)
Case REG_MULTI_SZ
StdOut.WriteLine "Data Type: Multi String"
StdOut.WriteBlankLines(1)
End Select
Next
Script End
-----------
How can I have this script let me know if the key exisits? It doesn't seem
to return an error until it hits the UBound (of course). Any ideas? I don't
cafre about the values in the key if it does exsist, I just want to know if
it is there or not.
Thanks