Const HKLM = &H80000002

arrNeededSvcs = Array("BITS","wuauserv")

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost"
strValueName = "netsvcs"

strComputer = "."   ' Utiliser "." pour local computer
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
                  & strComputer & "\root\default:StdRegProv")

objReg.GetMultiStringValue HKLM, strKeyPath, strValueName, arrValues

' create string from array, easier to check for existence this way
strValues = "|" & Join(arrValues, "|") & "|"

bolUpdateNeeded = False  ' init value

For Each strNeededSvcs In arrNeededSvcs
   If InStr(1, strValues, strNeededSvcs, vbTextCompare) = 0 Then
     ' service is not in array, add it
     intArrCount = UBound(arrValues) + 1
     ReDim Preserve arrValues(intArrCount)
     arrValues(intArrCount) = strNeededSvcs
     bolUpdateNeeded = True
   End If
Next

If bolUpdateNeeded Then
   objReg.SetMultiStringValue HKLM, strKeyPath, strValueName, arrValues
   'MsgBox arrValues
   MsgBox "Terminé : BITS et/ou wuauserv étai(en)t absent(s), la valeur a été mise à jour, rebootez", vbInformation + vbSystemModal, "Vérification Netsvcs"
End If

If not bolUpdateNeeded Then
   MsgBox "Terminé : aucune anomalie détectée", vbInformation + vbSystemModal, "Vérification Netsvcs"
End If


Set objReg = Nothing

