[VBS] Récupération info base de registre [RESOLU]

thepriest

Habitué
Bonjour à tous,

Voilà je suis en train de créer un petit VBS qui permet de controler la verison de Microsoft Office97 présente sur des pc sous NT4.

Le problème n'est pas le script en lui même vu qu'il fonctionne, je l'ai testé. mais le vrai noeud du problème est de connaître les versions existante de Ms Office97.
En effet, il y a au moins 4 versions:
- Office97 vierge de patch
- Office97 SR1
- Office97 SR2
- Office97 SR2a
- Office97 SR2b (1122)

Ce que j'aurai souhaité c'est disposer d'une liste complète des versions ayant existées, mais j'ai beau avoir chercher chez MS (MSDN et SDK), je n'y suis pas parvenu

[fixed]

'*****************************************
'
' This vbs is used to know the version of
' the release of ' the Microsoft office97
' installed in NT computers.
'
' Pay attention this script run only for
' computer under NT & MsOffice97
'
'*****************************************

' Turn error detection off
On Error Resume Next

Dim strComputer, strSubKey, ValueName, ValueVersion, ValueVersionExt, ValueFullName1, ValueFullName2
Dim strDisplayValue , cpt
Dim strRegKey1
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strOldName = objReg.RegRead(strRegKey1)

'****************************************************************
' Modify the strRegKey1 to verify the registry you want to check
' and don't remember to modify the ValueName
'****************************************************************

strRegkey1 = "SOFTWARE\Microsoft\MS Setup (ACME)\Table Files"

ValueFullName1 = "MS Office 97 Professional@v97.0.0.1122(1033)"
'ValueFullName2 = "MS Office 97 Professional@v97.0.0.1117(1033)"
'ValueFullName3 = "MS Office 97 Professional@v97.0.0.1114(1033)"


'With this method we build the ValueFullName thus is dynamic with an inputbox
'ValueFullName = ValueName & InputBox ("Please put the version of Microsoft Office97 you want to check", "Version : ") & ValueVersionExt


If Err.Number <> 0 Then
' Key existed
' Capture the information

Set objRegistry = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

objRegistry.EnumKey HKEY_LOCAL_MACHINE, strRegKey1, arrSubKeys

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strRegKey1 , ValueFullName1, strDisplayValue

'Place here the select case proposale when
'we have all the Office97 version

'Select Case someVariable
'Case "something"
'do some code
'Case "somethingelse"
'do a diferent line of code
'Case Else
'do a default statement
'End Select


If strDisplayValue <> "" Then
MsgBox("Key present !" & vbcrlf & "You have a Microsoft Office97 RC2 installed" )
Else
MsgBox("Key does not exist")
End If

strDisplayValue = vbEmpty

Else
' Key did not exist
MsgBox("Key does not exist")
End If

' Turn error detection back on
On Error Goto 0

[/fixed]

En attendant une réponse d'une personne qui a la connaissance, passez une bonne journée/soirée

:merci:
 

thepriest

Habitué
Bon, il me semble qu'il y a peu de personne qui ai connaissance des informations sur les versions des releases de Office :(

J'ai essayé de faire une autre méthode et j'ai pu glanner ici et là des info mais bien trop sommaires.

Voici le code que j'utiliserai :

[fixed]

'*****************************************
'
' This vbs was created by Alan Stanfeld
' to know the version of the release of
' the Microsoft office97 installed in NT
' computers
'
' Pay attention this script run only for
' computer under NT4 & MsOffice97
'
'*****************************************

' Turn error detection off
On Error Resume Next

Dim strComputer, strSubKey, ValueName, ValueVersion, ValueVersionExt
Dim ValueFullName1, ValueFullName2, ValueFullName3
Dim strDisplayValue1, strDisplayValue2, strDisplayValue3
Dim str1, str2, str3
Dim strRegKey1

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

strRegkey1 = "SOFTWARE\Microsoft\MS Setup (ACME)\Table Files"

strOldName = objReg.RegRead(strRegKey1)



'*********************************************
' Modify the strRegKey1 to verify the *
' registry you want to check *
' and don't remember to modify the ValueName *
'*********************************************


'This is the value for the different release of the Office97

ValueFullName1 = "MS Office 97 Professional@v97.0.0.1122(1033)"
ValueFullName2 = "MS Office 97 Professional@v97.0.0.1117(1033)"
ValueFullName3 = "MS Office 97 Professional@v97.0.0.1114(1033)"


'With this method we build the ValueFullName thus is dynamic with an inputbox
'ValueFullName = ValueName & InputBox ("Please put the version of Microsoft
'Office97 you want to check", "Version : ") & ValueVersionExt


If Err.Number <> 0 Then

' Key existed
' Capture the information

Set objRegistry = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

objRegistry.EnumKey HKEY_LOCAL_MACHINE, strRegKey1, arrSubKeys

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strRegKey1 , ValueFullName1, strDisplayValue1

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strRegKey1 , ValueFullName2, strDisplayValue2

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strRegKey1 , ValueFullName3, strDisplayValue3


'msgBox(strDisplayValue1)

If strDisplayValue1 = "C:\Program Files\Microsoft Office\Office\Setup\Off97Pro.STF" Then
Str1 = "You have a Microsoft Office97 SR2-B installed"
Else Str1 = ""
End If

'msgBox(strDisplayValue1 & " || " & str1)

'msgBox(strDisplayValue2)

If strDisplayValue2 = "C:\Program Files\Microsoft Office\Office\Setup\Off97Pro.STF" Then
Str2 = "You have a Microsoft Office97 SR2-A installed"
Else Str2 = ""
End If

'msgBox(strDisplayValue2 & " || " & str2)

'msgBox(strDisplayValue3)

If strDisplayValue3 = "C:\Program Files\Microsoft Office\Office\Setup\Off97Pro.STF" Then
Str3 = "You have a Microsoft Office97 SR1 installed"
Else Str3 = ""
End If

'msgBox(strDisplayValue3 & " || " & str3)

'MsgBox(Str1)
'MsgBox(Str2)
'MsgBox(Str3)


If (Str1 = "" and Str2 = "" and Str3 = "") Then
MsgBox("Key does not exist or may different !")
ElseIf (Str1 <> "" and Str2 = "" and Str3 = "") Then
MsgBox (Str1)
ElseIf (Str2 <> "" and Str1 = "" and Str3 = "") Then
MsgBox (Str2)
ElseIf (Str3 <> "" and Str2 = "" and Str1 = "") Then
MsgBox (Str3)
Else
MsgBox ("You have an another version of the release !")
End If


Str1 = ""
Str2 = ""
Str3 = ""

strDisplayValue1 = ""
strDisplayValue2 = ""
strDisplayValue3 = ""


Else
' Key did not exist
MsgBox("Key does not exist You have probably an Office 2000/Xp !")
End If


' Turn error detection back on
On Error Goto 0

[/fixed]
 

thepriest

Habitué
Bon ben voici une autre solution que j'ai développé plus souple:

Elle permet de récupérer facilement des clés de la base de registre

[fixed]

'**************************************
'
' This function check a particular
' Key in the registry to show it
' in a Excel sheet
'
' Parameters are the following :
' -PCName : the computer name on the network
' -RegKey : the name of the whole key that you
' want check or know the version
' -ValueName: name of the value that you want
' keep.
'**************************************

Function SoftVersion (PCName,RegKey,ValueName,SoftName)

On Error Resume Next

Dim strComputer, strSubKey
Dim ValueFullName
Dim strDisplayValue
Dim str
Dim strRegKey1, Res

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = PCNAME

strRegkey = RegKey

strOldName = objReg.RegRead(strRegKey1)

ValueFullName = ValueName

If Err.Number <> 0 Then

Set objRegistry = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\default:StdRegProv")

objRegistry.EnumKey HKEY_LOCAL_MACHINE, strRegKey, arrSubKeys

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strRegKey , ValueFullName, strDisplayValue

If strDisplayValue <> "" Then
Res = strDisplayValue
Else Res = ""
End If

Else
' Key did not exist
Res = "Key does not exist !"
End If

' Turn error detection back on
On Error Goto 0

call show(PCNAME,SoftName,Res,"N/A")

End function
[/fixed]
 
Vous devez vous inscrire ou vous connecter pour répondre ici.
Derniers messages publiés
Statistiques globales
Discussions
730 098
Messages
6 717 065
Membres
1 586 286
Dernier membre
petitangebleu1977
Partager cette page
Haut