I need a vbscript function that can return a value if a registry keys exists on a remote machine.

how can I achieve this ?
itbabeAsked:
Who is Participating?
 
prashanthdConnect With a Mentor Commented:
Added the function part..
Function RegEntryExists(strComputer)
    
    HKEY_LOCAL_MACHINE = &H80000002
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\RealNetworks\RealPlayer"
    If oReg.EnumKey (HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys) = 0 Then
        WScript.Echo "Exists"
        RegEntryExists=True
    Else
        WScript.Echo "Not Exists"
        RegEntryExists=False
    End If 
    
End Function

Open in new window

0
 
prashanthdCommented:
Try the following

regards
Prashanth
HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\RealNetworks\RealPlayer"
If oReg.EnumKey (HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys) = 0 Then
    WScript.Echo "Exists"
Else
    WScript.Echo "Not Exists"
End If

Open in new window

0
 
Dhiraj MuthaLevel DCommented:
Hope this helps:
Dim var, strComputer 
strComputer = 127.0.0.1 
var = RegRead("\\" & strComputer & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") 
MsgBox "Program files are in: " & var

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.