VBA code to Get registry from PC

Derek

Registered User.
Local time
Today, 15:46
Joined
May 4, 2010
Messages
234
Hi All

I want VBA code to get registry from my PC. So basically I want to put some conditions in the workbook like if registry=something then do this Else do something different.

Any help would be much appreciated.

Thanks
 
Like when we go to Start->My computer->View System Information

then in General tab , there is "Registered To" so I want that value using VbA
 
Thanks Jdraw. Which function I need to use to just display "Registered to" information. Thanks
 
?? Show me the jpg of the screen with the Registered To info --black out anything you don't want public.
When I look at me System Info, I don't see a registered to.????
 
Don't know.. I have windows 8.1 64bit and it doesn't show a registered to.

I would try searching for winmgmts examples
 

Attachments

  • sysinfo.jpg
    sysinfo.jpg
    65 KB · Views: 142
Last edited:
ok so can you please help me to display "registered to" information. So basically in my example I want to display "Friends Provident"
 
Did a bit more investigating and 'RegisteredOrganization' is a standard value in the registry but is not always completed.

attachment.php


You will find it in this path in the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
 

Attachments

  • Capture.JPG
    Capture.JPG
    37.8 KB · Views: 739
After some testing and CJ's link I found some material and wrote the proc below.
I also looked in to the registry to see what values were there.

There is no RegisteredTo in my Registry. And RegisteredTo gave an error in my code. I bypassed the error with the On Error Resume Next.



Code:
'---------------------------------------------------------------------------------------
' Procedure : jackfeb5
' Author    : mellon
' Date      : 05/02/2015
' Purpose   : Using WScript to get registry key values.
' I do not have values for RegisteredTo or RegisteredOrganization
'
'RegisteredTo may be an invalid name , it gives me a can't open for read
'so I added the error/resume to bypass and continue
'---------------------------------------------------------------------------------------
'
Sub jackfeb5()
          Dim myWS As Object
          Dim OpSystem As String
          Dim RegisteredTo As String
          Dim RegisteredOwner As String
          Dim RegisteredOrganization As String

10        On Error Resume Next  'added because it gives an error on RegisteredTo
                                 'unable to open registry key for Reading???
          'access Windows scripting
20        Set myWS = CreateObject("WScript.Shell")

          'read key from registry,
          'Who Windows is registered to?
          'Who is the Owner
          'Who is organization
30        RegisteredTo = myWS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredTo")
40        RegisteredOwner = myWS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner")
50        RegisteredOrganization = myWS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization")
60        Debug.Print "RegisteredTo " & RegisteredTo
70        Debug.Print "RegisteredOwner " & RegisteredOwner
80        Debug.Print "RegisteredOrganization " & RegisteredOrganization

          'read key from registry, what version of Windows?
90        OpSystem = myWS.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
100       Debug.Print "OpSystem " & OpSystem
End Sub

Results on my Machine:

Code:
RegisteredTo 
RegisteredOwner mellon '<<=====that's my PC name
RegisteredOrganization 
OpSystem Windows 8.1
 
I think the OP needs to open the registry and navigate to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\

and see what keys are there - it may well be that although the text says 'registered to', the key is called something else.

for example, this link

http://www.howtogeek.com/howto/wind...e-manufacturer-support-info-in-windows-vista/

has SupportHours in the key, but Support hours: on the general tab - and completely different for the URL

OK, it's for Vista, and shows different keys but the principle demonstrated is you can add keys, and what is in the key is not what is in the general tab.

It looks like the OP's company is of a size where they will have a substantial IT department, so it may well be worth talking to them.
 
CJ I agree 100%. In my case I had no RegisteredTo in the registry when I viewed via regedit, and no such entry/display on my sysinfo screen
 
I've done some further investigation and it appears there is an ini file that can be created and does not use the registry - just google oeminfo.ini for plenty of posts on the subject - here are a couple.

https://technet.microsoft.com/en-gb/library/cc748975(v=ws.10).aspx
http://www.tomshardware.co.uk/forum/152125-30-oeminfo-post-demo-sample

The bit of interest is most easily visible in the second link above in the support information section - here you can see entries like

Line6="Technical Support Mail: poopy@aol.net"

Which could easily translate to

Line6="Registered To: somecompany"

The ini file, if it exists is in the c:\windows\system folder

So my suggestion to the OP is to see if this ini file exists in the system directory
 
Search shows No oeminfo.ini on my PC.
 
Search shows No oeminfo.ini on my PC.
Nor mine, but it can be created - usually by oem manufacturers hence the name. I'm on a voyage of discovery with this since it is an unusual requirement and I'm just suggesting it could be on the OP's machine since it looks like he works for a large organisation and their IT department will be supplying and maintaining the pc's. I know from my own experience with my larger clients that they put additional information on the system screen - things like organisation name, helpdesk number/links, reference codes for machine asset ID. I've just never given it any thought before about how they do that - now I know!

But it looks like the OP has gone away, he hasn't responded to any of my suggestions so I guess we'll never know for sure. I've enjoyed the diversion but now need to get on with other things.
 

Users who are viewing this thread

Back
Top Bottom