Accès à une base de registre distante
Bonjour,
Je souhaiterai via mon fichier excel savoir si un PC du réseau à tel ou tel composant installé.
Par exemple ==> Framework 4.0.
Il y a pas mal d'info sur le net sur le sujet, mais je n'arrive pas à appliquer ce qu'il est décrit.
Je suis arrivé à le faire pour mon poste (local)
Code:
1 2 3 4 5 6 7 8 9 10
| Dim WS As Object
Dim R As String
Dim cleregistre As String
cleregistre = "HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\v4.0.30319\AspNetEnforceViewStateMac"
Set WS = CreateObject("WScript.Shell")
On Error Resume Next
R = WS.RegRead(cleregistre)
MsgBox R |
Je souhaiterai faire de même sur un PC du réseau
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
Sub
Const HKEY_LOCAL_MACHINE = &H80000002
Dim StrKeyPath As String
Dim ArSubKey As String
Dim oReg As Object
Dim StrValueName As String
Dim StrValue As String
Dim strCompute As String
strCompute = "Mon_PC"
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strCompute & "\root\default:StdRegProv")
StrKeyPath = "HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\v4.0.30319\"
oReg.EnumKey HKEY_LOCAL_MACHINE, StrKeyPath, arrSubKeys
For Each subkey In arrSubKeys
If Left(subkey, 4) = "KEY_" Then
StrValueName = "test"
oReg.GetStringValue HKEY_LOCAL_MACHINE, StrKeyPath & "\" & subkey, StrValueName, StrValue
If result = "" Then
result = StrValue
Else
result = result & ";" & StrValue
End If
End If
Next
End Sub |
Si vous avez des pistes, je suis preneur :)
Merci & bonne journée!