Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Accessing Remote registry in Excel

I have a list of servers in excel and I would like to access a few
registry setting on each server and write that value to other column.
Can anyone help with this? I do not need to write to the registry,
just read.

Thanks in advance
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Accessing Remote registry in Excel

Ignore that last post. It'll work if you want to save or retrieve a setting for
your VBA program--but it's not used for accessing the registry in general:

Option Explicit

Sub testme()
Dim wsh As Object
Dim RegStr As String
Dim RegVal As String

RegStr = "HKLM\Software\Microsoft\mediaplayer\" _
& "settings\mp3encoding\PreferredCodecName"

Set wsh = CreateObject("WScript.Shell")

RegVal = "not found!!!!"
On Error Resume Next
RegVal = wsh.RegRead(RegStr)
On Error GoTo 0

If RegVal = "not found!!!!" Then
MsgBox "key wasn't found"
Else
MsgBox RegVal
End If
End Sub



wrote:

I have a list of servers in excel and I would like to access a few
registry setting on each server and write that value to other column.
Can anyone help with this? I do not need to write to the registry,
just read.

Thanks in advance


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Accessing Remote registry in Excel

Ahhhh.

Please ignore both these posts.

I have no idea how to access the registry on a server.

If you don't get a real answer in this newsgroup, you may want to post in a VB
newsgroup--explain that you want to use it in excel's VBA and maybe you'll get a
response you don't have to tweak.

Dave Peterson wrote:

Ignore that last post. It'll work if you want to save or retrieve a setting for
your VBA program--but it's not used for accessing the registry in general:

Option Explicit

Sub testme()
Dim wsh As Object
Dim RegStr As String
Dim RegVal As String

RegStr = "HKLM\Software\Microsoft\mediaplayer\" _
& "settings\mp3encoding\PreferredCodecName"

Set wsh = CreateObject("WScript.Shell")

RegVal = "not found!!!!"
On Error Resume Next
RegVal = wsh.RegRead(RegStr)
On Error GoTo 0

If RegVal = "not found!!!!" Then
MsgBox "key wasn't found"
Else
MsgBox RegVal
End If
End Sub

wrote:

I have a list of servers in excel and I would like to access a few
registry setting on each server and write that value to other column.
Can anyone help with this? I do not need to write to the registry,
just read.

Thanks in advance


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Accessing Remote registry in Excel

You sure try hard and solve most!

Dave Peterson wrote:

Ahhhh.

Please ignore both these posts.

I have no idea how to access the registry on a server.

If you don't get a real answer in this newsgroup, you may want to post in a VB
newsgroup--explain that you want to use it in excel's VBA and maybe you'll get a
response you don't have to tweak.

Dave Peterson wrote:

Ignore that last post. It'll work if you want to save or retrieve a setting for
your VBA program--but it's not used for accessing the registry in general:

Option Explicit

Sub testme()
Dim wsh As Object
Dim RegStr As String
Dim RegVal As String

RegStr = "HKLM\Software\Microsoft\mediaplayer\" _
& "settings\mp3encoding\PreferredCodecName"

Set wsh = CreateObject("WScript.Shell")

RegVal = "not found!!!!"
On Error Resume Next
RegVal = wsh.RegRead(RegStr)
On Error GoTo 0

If RegVal = "not found!!!!" Then
MsgBox "key wasn't found"
Else
MsgBox RegVal
End If
End Sub

wrote:

I have a list of servers in excel and I would like to access a few
registry setting on each server and write that value to other column.
Can anyone help with this? I do not need to write to the registry,
just read.

Thanks in advance


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Accessing Remote registry in Excel

Try the vbscript group: this is the type of thing vbscript gets used for a
lot.

Tim

wrote in message
...
I have a list of servers in excel and I would like to access a few
registry setting on each server and write that value to other column.
Can anyone help with this? I do not need to write to the registry,
just read.

Thanks in advance



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Accessing Remote registry in Excel



Thanks
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Accessing Remote registry in Excel

On Aug 6, 8:54*am, wrote:
Thanks


I got a VBS script to work pulling remote registry data - could you
guys help me now figure ut how to put this into excel please??


-- code --


On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "remoteServer"
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root
\default:StdRegProv")
strKeyPath = "SOFTWARE\AssetInfo"

AssetTag = "AssetTag"
SerialNumber = "SerialNumber"

objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, AssetTag,
strValue1
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath,
SerialNumber, strValue2

Wscript.Echo strValue1
Wscript.Echo strValue2


-- code --

Now I jsut need it to pull the strComputer from like excel cell A2 and
then instead of echo put the value in B2 and so on...

Thanks in advance.


JD
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Accessing Remote registry in Excel

Untested, but it did compile:

Option Explicit
Sub testme02()

Dim myRng As Range
Dim myCell As Range
Dim strValue1 As String
Dim strValue2 As String
Dim strComputer As String
Dim objReg As Object
Dim strKeyPath As String
Dim AssetTag As String
Dim SerialNumber As String

Const HKEY_LOCAL_MACHINE = &H80000002

With Worksheets("sheet1")
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

On Error Resume Next
For Each myCell In myRng.Cells

strComputer = myCell.Value
Set objReg = GetObject("winmgmts:\\" & strComputer _
& "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\AssetInfo"

AssetTag = "AssetTag"
SerialNumber = "SerialNumber"

objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, _
AssetTag, strValue1

objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, _
SerialNumber, strValue2

myCell.Offset(0, 1).Value = strValue1
myCell.Offset(0, 2).Value = strValue2

Next myCell
On Error GoTo 0

End Sub

wrote:

On Aug 6, 8:54 am, wrote:
Thanks


I got a VBS script to work pulling remote registry data - could you
guys help me now figure ut how to put this into excel please??

-- code --

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "remoteServer"
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root
\default:StdRegProv")
strKeyPath = "SOFTWARE\AssetInfo"

AssetTag = "AssetTag"
SerialNumber = "SerialNumber"

objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, AssetTag,
strValue1
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath,
SerialNumber, strValue2

Wscript.Echo strValue1
Wscript.Echo strValue2

-- code --

Now I jsut need it to pull the strComputer from like excel cell A2 and
then instead of echo put the value in B2 and so on...

Thanks in advance.

JD


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Accessing Remote registry in Excel

On Aug 6, 2:43*pm, Dave Peterson wrote:
Untested, but it did compile:

Option Explicit
Sub testme02()

* * Dim myRng As Range
* * Dim myCell As Range
* * Dim strValue1 As String
* * Dim strValue2 As String
* * Dim strComputer As String
* * Dim objReg As Object
* * Dim strKeyPath As String
* * Dim AssetTag As String
* * Dim SerialNumber As String

* * Const HKEY_LOCAL_MACHINE = &H80000002

* * With Worksheets("sheet1")
* * * * Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
* * End With

* * On Error Resume Next
* * For Each myCell In myRng.Cells

* * * * strComputer = myCell.Value
* * * * Set objReg = GetObject("winmgmts:\\" & strComputer _
* * * * * * * * * * * * * * & "\root\default:StdRegProv")
* * * * strKeyPath = "SOFTWARE\AssetInfo"

* * * * AssetTag = "AssetTag"
* * * * SerialNumber = "SerialNumber"

* * * * objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, _
* * * * * * * * * * * * * * * * * AssetTag, strValue1

* * * * objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, _
* * * * * * * * * * * * * * * * * SerialNumber, strValue2

* * * * myCell.Offset(0, 1).Value = strValue1
* * * * myCell.Offset(0, 2).Value = strValue2

* * Next myCell
* * On Error GoTo 0

End Sub





wrote:

On Aug 6, 8:54 am, wrote:
Thanks


I got a VBS script to work pulling remote registry data - could you
guys help me now figure ut how to put this into excel please??


-- code --


On Error Resume Next


Const HKEY_LOCAL_MACHINE = &H80000002


strComputer = "remoteServer"
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root
\default:StdRegProv")
strKeyPath = "SOFTWARE\AssetInfo"


AssetTag = "AssetTag"
SerialNumber = "SerialNumber"


* * objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, AssetTag,
strValue1
* * objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath,
SerialNumber, strValue2


* * Wscript.Echo strValue1
* * Wscript.Echo strValue2


-- code --


Now I jsut need it to pull the strComputer from like excel cell A2 and
then instead of echo put the value in B2 and so on...


Thanks in advance.


JD


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks -

I am not very proficient in excel but I think I am doing it right...

I went to Tool Macros VB Editor and copied this to This Workbook -
Saved and ran. Took a while and did not post anythign to the
workbook. I only have about 5 servers listed for testing and tried to
debug - it goes through the loop well over 100 times - in theroy it
should only go through the loop 6 times... I stopped the debug at that
point - any suggestions? It is sheet 1, servers are listed a2 - a6.

Any thoughts?

JD
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a Remote Server pdberger Excel Programming 0 June 17th 07 07:48 PM
error accessing system registry Donna Excel Discussion (Misc queries) 2 July 11th 06 09:22 PM
Excel VBA- Error Accessing the system registry pie[_2_] Excel Programming 0 April 21st 04 05:06 AM
Error accessing the system registry Daphne W Excel Programming 2 April 15th 04 03:50 AM
Error Accessing the OLE Registry Kevin Excel Programming 0 August 13th 03 11:02 PM


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"