OVH Cloud OVH Cloud

lecture registre a distance

3 réponses
Avatar
patoche
Bonjour,

Existe t il un moyen d'interroger un registre a distance ? le but etant de
recenser toutes les applications d'installer dessus.

Merci d'avance

3 réponses

Avatar
Stéphane [MS]
Bonjour,

Oui, c'est possible, mais le plus simple est d'utiliser WMI comme dans le
script suivant extrait de Script Center que vous pouvez adapter en modifiant
la variable strComputer :

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:scriptssoftware.tsv", True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"

For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallDate2 & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close

Cdlt
Stéphane

"patoche" a écrit dans le message de
news:
Bonjour,

Existe t il un moyen d'interroger un registre a distance ? le but etant
de
recenser toutes les applications d'installer dessus.

Merci d'avance



Avatar
patoche
Merci de votre reponse.
Par contre, ce programme liste que les applications installées via windows
installer.
J aimerais aussi avoir les autres, c'est de la que vient l idee de lire le
registre. Si vous avez une idee, comment lire un registre a distance, je suis
preneur ?

Merci d'avance


Bonjour,

Oui, c'est possible, mais le plus simple est d'utiliser WMI comme dans le
script suivant extrait de Script Center que vous pouvez adapter en modifiant
la variable strComputer :

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:scriptssoftware.tsv", True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"

For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallDate2 & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close

Cdlt
Stéphane

"patoche" a écrit dans le message de
news:
Bonjour,

Existe t il un moyen d'interroger un registre a distance ? le but etant
de
recenser toutes les applications d'installer dessus.

Merci d'avance








Avatar
Jean-Claude BELLAMY
Dans le message news: ,
patoche s'est ainsi exprimé:

Merci de votre reponse.
Par contre, ce programme liste que les applications installées via
windows installer.
J aimerais aussi avoir les autres, c'est de la que vient l idee de
lire le registre. Si vous avez une idee, comment lire un registre a
distance, je suis preneur ?


Il suffit de faire appel à la classe "StdRegProv"
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/stdregprov.asp

Fichier "EnumSoftware.vbs"
--------- couper ici ---------
Const HKEY_LOCAL_MACHINE = &H80000002
Set net = Wscript.CreateObject("WScript.Network")
Set args = Wscript.Arguments
nbargs=args.count
if nbargs=0 then strComputer=net.ComputerName else strComputer=args(0)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!" & _
strComputer & "rootdefault:StdRegProv")
Dim sKeys
CodeRet = oReg.EnumKey(HKEY_LOCAL_MACHINE, "Software", sKeys)
msg= "Liste des clefs HKLMSoftware de l'ordinateur " & strComputer
msg=msg & VBCRLF & String(len(msg),"-") & VBCRLF
If (CodeRet = 0) And (Err.Number = 0) Then
For i= LBound(sKeys) To UBound(sKeys)
msg=msg & VBCRLF & sKeys(i)
next
wscript.echo msg
end if
--------- couper ici ---------


Exemples :

I:Program FilesVBS>enumsoftware.vbs SASSANDRA
Liste des clefs HKLMSoftware de l'ordinateur SASSANDRA
-------------------------------------------------------
Acronis
Adobe
ADS Tech
Agere
Ahead
Alps
Andrea Electronics
Apple Computer, Inc.
...
VMware, Inc.
Widcomm
Windows 3.1 Migration Status


I:Program FilesVBS>enumsoftware.vbs
Liste des clefs HKLMSoftware de l'ordinateur GRANDBASSAM
---------------------------------------------------------
321Studios
ACD Systems
Acronis
...
Wise Solutions
Xing Technology Corp.
Xteq Systems


A toi d'adapter à tes besoins !

--
May the Force be with You!
La Connaissance s'accroît quand on la partage
----------------------------------------------------------
Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org
*