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
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Accessing Remote registry in Excel

First, the code shouldn't be under the ThisWorkbook module.

Take a look at Debra Dalgleish's site for instructions for placing the code in a
general module.
http://contextures.com/xlvba01.html#Regular

Second, I don't see anything in the code I posted that would cause the loop to
be executed 100 times. Maybe you have an event macro running????

I don't see why the code would loop more than 5 times (5 cells in A2:A6).



wrote:
<<snipped

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


--

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

On Aug 6, 4:10*pm, Dave Peterson wrote:
First, the code shouldn't be under the ThisWorkbook module.

Take a look at Debra Dalgleish's site for instructions for placing the code in a
general module.http://contextures.com/xlvba01.html#Regular

Second, I don't see anything in the code I posted that would cause the loop to
be executed 100 times. *Maybe you have an event macro running????

I don't see why the code would loop more than 5 times (5 cells in A2:A6).

wrote:

<<snipped



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


--

Dave Peterson


Good article for noobs -

Plus I forgot I was opening excel with a reg user account - once I
runas with a admin account that has access to the servers it works -
this is very cool!!

I have added about 15 reg keys that I want to get values from and they
all pull into excel. I am guessing I will use this code for a long
time to come in the future - thanks for your help!!!!

This will make my life easy since I have about 150 servers I want data
from


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

On Aug 6, 7:14*pm, Dave Peterson wrote:
Glad you got it working--and thanks for posting back the details.

I'm not sure where you got the .VBS script from, but you may want to drop off a
note of thanks to that guy/gal, too.







wrote:

<<snipped

Good article for noobs -


Plus I forgot I was opening excel with a reg user account - once I
runas with a admin account that has access to the servers it works -
this is very cool!!


I have added about 15 reg keys that I want to get values from and they
all pull into excel. *I am guessing I will use this code for a long
time to come in the future - thanks for your help!!!!


This will make my life easy since I have about 150 servers I want data
from


JD


--

Dave Peterson- Hide quoted text -

- Show quoted text -


I figured that out on my own from technet articles....

http://msdn.microsoft.com/en-us/libr...00(VS.85).aspx



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

It's time to buy yourself a nice cold drink in thanks <vbg.



wrote:

<<snipped

I figured that out on my own from technet articles....

http://msdn.microsoft.com/en-us/libr...00(VS.85).aspx

--

Dave Peterson
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 12:47 AM.

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

About Us

"It's about Microsoft Excel"