Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Look at GetSetting in VBA's help. It has an example, too.
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Accessing a Remote Server | Excel Programming | |||
error accessing system registry | Excel Discussion (Misc queries) | |||
Excel VBA- Error Accessing the system registry | Excel Programming | |||
Error accessing the system registry | Excel Programming | |||
Error Accessing the OLE Registry | Excel Programming |