?
Solved

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

Posted on 2011-05-03
3
Medium Priority
?
388 Views
Last Modified: 2012-05-11
how can I achieve this ?
0
Comment
Question by:itbabe
  • 2
3 Comments
 
LVL 12

Expert Comment

by:prashanthd
ID: 35511651
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
 
LVL 14

Expert Comment

by:Dhiraj Mutha
ID: 35511656
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
 
LVL 12

Accepted Solution

by:
prashanthd earned 2000 total points
ID: 35512495
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month17 days, 9 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question