Solved

Remote registry lookup program

Posted on 2003-11-19
8
548 Views
Last Modified: 2010-04-17
basically i want to look at a key in the registry that holds a "PC build number" of what build we are currently on at our firm and have it display on screen.. I would prefer to have it be an exe... and ideally be able to run it to look up networked PCs build number by entering the PC name and it displaying the value of that key... The key is under HKLM\Software\Firm which stands for our firm.
0
Comment
Question by:microIT
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:Insolence
ID: 9784411
Do you want someone to code this up for you and upload the source or exe, or something, if so I think you'll need to bump those points up.  =P

 - Insolence
0
 

Author Comment

by:microIT
ID: 9784488
I actually would like to do it mostly myself. i am not a hardcore programmer but i can get suggestions on what language to use and some tidbits here and there i would like to try this one. you are right, i'll bump it up.
0
 
LVL 22

Expert Comment

by:cookre
ID: 9784560
It's really pretty simple, just use RegConnectRegistry() to open a remote key, then use the normal registry calls to work with it.

0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 22

Accepted Solution

by:
cookre earned 200 total points
ID: 9784596
Like this:
rc=RegConnectRegistry(RemoteName,HKLM,&RemoteHKLM);
rc=RegOpenKeyEx(RemoteHKLM,"Software\\MegaSysCorp",NULL,KEY_ALL_ACCESS,&TargetKey);
rc=RegQueryValueEx(TargetKey,"ValueName",NULL,NULL,strValueValue,&dwSize);

0
 

Author Comment

by:microIT
ID: 9784598
Mainly when i need to do something registrywise i'll use vbs.. is the function you mentioned above a function of vbs? i want to eventually tie it to a GUI or something so that you can enter the PC name and it will retrieve the key value... sorry i'm so clueless when it comes to this script, it would be very useful though because we are changing our build frequently.
0
 

Author Comment

by:microIT
ID: 9784600
the key will always be the same so that should be the easy part entering a static path.
0
 
LVL 22

Expert Comment

by:cookre
ID: 9784722
I don't know about VBS, but a VB EXE needs declarations of the API calls like this:

declare function RegConnectRegistry  _
                         lib "advapi32.dll" alias "RegConnectRegistryA"  _
                        (ByVal lpMachineName As String, ByVal hKey As Long, phkResult As Long)  _
                        As Long

declare function RegOpenKeyEx  _
                       lib "advapi32.dll" alias "RegOpenKeyExA"  _
                      (ByVal hKey As Long  _
                      ,ByVal lpSubKey As String _
                      ,ByVal ulOptions As Long _
                      ,ByVal samDesired As Long _
                      ,phkResult As Long) _
                      As Long

declare function RegQueryValueEx _
                      Lib "advapi32.dll" Alias "RegQueryValueExA" _
                     (ByVal hKey As Long _
                     ,ByVal lpValueName As String _
                     ,ByVal lpReserved As Long _
                     ,lpType As Long _
                     ,lpData As Any _
                     ,lpcbData As Long) _
                     As Long

declare function RegCloseKey Lib "advapi32.dll"  (ByVal hKey As Long) As Long




0
 
LVL 22

Expert Comment

by:cookre
ID: 9784747
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

809 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