TUTOS.EU

Lister les mises à jour Windows disponibles

Comment établir la liste des mises à jour disponibles sur une machine. Il est recommandé d'en faire l'historique avant application, au cas où l'un d'eux pose problème. Collez le script dans le répertoire, lancez le et un fichier sera généré automatiquement.

'2014 octobre 28 version : add name server on file generated
'http://www.chdb.eu/?n=4272
'Just copy on the folder where you want generated history file.

Dim ActualDay
Dim MyDay
Dim MyMonth
Dim objFSO
Dim objTextFile
Dim CheminFichier
Dim CheminScriptActuel
Dim WSHShell
Dim vCOMPUTERNAME

'Déclaration des constantes
Const ForReading = 1
Const ForWritting = 2
Const ForAppending = 8

'Determine actual date
MyDay = Day(Now)
MyMonth = Month(Now)

If Len(MyDay) = 1 Then
	MyDay = "0" & MyDay
End If

If Len(MyMonth) = 1 Then
	MyMonth = "0" & MyMonth
End If
ActualDay = Year(Now) & "-" & MyMonth & "-" & MyDay

Set WSHShell = CreateObject("WScript.Shell") 
vCOMPUTERNAME = WSHShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

CheminScriptActuel = Left(wscript.scriptfullname,Len(wscript.scriptfullname)-Len(wscript.scriptname)-1)
CheminFichier = CheminScriptActuel & "\" & vCOMPUTERNAME & "_ListUpdatesAvailables_" & ActualDay & ".txt" 'Déclaration du chemin et du nom du fichier


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(CheminFichier, ForWritting, True)

Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount

Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)

Set objSearcher = objSession.CreateupdateSearcher()
'WScript.Echo "Searching for available updates..." & vbCRLF

Set searchResult = objSearcher.Search("IsInstalled=0")
objTextFile.WriteLine("List of applicable items on the machine:")
For I = 0 To searchResult.Updates.Count-1
	Set update = searchResult.Updates.Item(I)
	objTextFile.WriteLine(update.Title)
Next

'For Each objEntry in colHistory
	'Wscript.Echo "Operation: " & objEntry.Operation
	'Wscript.Echo "Result code: " & objEntry.ResultCode
	''Wscript.Echo "Exception: " & objEntry.Exception
	'Wscript.Echo "Date: " & objEntry.Date
	'Wscript.Echo "Title: " & objEntry.Title
	'Wscript.Echo "Description: " & objEntry.Description
	''Wscript.Echo "Unmapped exception: " & objEntry.UnmappedException
	'Wscript.Echo "Client application ID: " & objEntry.ClientApplicationID
	'Wscript.Echo "Server selection: " & objEntry.ServerSelection
	'Wscript.Echo "Service ID: " & objEntry.ServiceID
	'i = 1
	'For Each strStep in objEntry.UninstallationSteps
		'Wscript.Echo i & " -- " & strStep
		'i = i + 1
	'Next
	''Wscript.Echo "Uninstallation notes: " & objEntry.UninstallationNotes
	''Wscript.Echo "Support URL: " & objEntry.SupportURL
	'Wscript.Echo
'Next

objTextFile.Close 'Fermeture du fichier

Set objTextFile = Nothing
Set objFSO = Nothing
Lien vers le fichier : cliquez ici

Article(s) précédent(s)