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
(E-Mail Removed) wrote:
>
> On Aug 6, 8:54 am, newsgroups...@gmail.com 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