J'étais curieux de savoir s'il y a une API .Net qui me permettrait d'identifier les mises à jour sont en attente pour « Windows Update »,.Net Windows Update Interrogation
défaut, est-il une commande Windows PowerShell qui peut l'obtenir ?
J'étais curieux de savoir s'il y a une API .Net qui me permettrait d'identifier les mises à jour sont en attente pour « Windows Update »,.Net Windows Update Interrogation
défaut, est-il une commande Windows PowerShell qui peut l'obtenir ?
L'API Windows Update Agent peut être ce que vous cherchez:
http://msdn.microsoft.com/en-us/library/aa387287%28VS.85%29.aspx
Il est une interface COM (non native .NET), mais vous pouvez consommer que de votre application.
Ce n'est pas si trivial du tout, mais vous pouvez juste faire référence à la bibliothèque de types COM/WUAPI 2.0, et VS crée un wrapper managé pour vous, qui est copié dans le répertoire de construction en tant que WuApiLib.dll.
Faites attention aux fuites de mémoire.
Voici un VBScript que vous pouvez utiliser pour installer des mises à jour avec
http://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx
Vous pouvez utiliser un objet COM très facilement dans PowerShell. Compte tenu de ce qui précède VBScript exemple, vous pouvez utiliser cet objet dans PS et
PS C:\> $updateSession = new-object -com Microsoft.update.Session
PS C:\> $updateSession | get-member
TypeName: System.__ComObject#{918efd1e-b5d8-4c90-8540-aeb9bdc56f9d}
Name MemberType Definition
---- ---------- ----------
CreateUpdateDownloader Method IUpdateDownloader CreateUpdateDownloader()
CreateUpdateInstaller Method IUpdateInstaller CreateUpdateInstaller()
CreateUpdateSearcher Method IUpdateSearcher CreateUpdateSearcher()
CreateUpdateServiceManager Method IUpdateServiceManager2 CreateUpdateServiceManager()
QueryHistory Method IUpdateHistoryEntryCollection QueryHistory (string, int, int)
ClientApplicationID Property string ClientApplicationID() {get} {set}
ReadOnly Property bool ReadOnly() {get}
UserLocale Property uint UserLocale() {get} {set}
WebProxy Property IWebProxy WebProxy() {get} {set}
PS C:\> $searcher = $updateSession.CreateUpdateSearcher()
PS C:\> $searcher | gm
TypeName: System.__ComObject#{04c6895d-eaf2-4034-97f3-311de9be413a}
Name MemberType Definition
---- ---------- ----------
BeginSearch Method ISearchJob BeginSearch (string, IUnknown, Variant)
EndSearch Method ISearchResult EndSearch (ISearchJob)
EscapeString Method string EscapeString (string)
GetTotalHistoryCount Method int GetTotalHistoryCount()
QueryHistory Method IUpdateHistoryEntryCollection QueryHistory (int, int)
Search Method ISearchResult Search (string)
CanAutomaticallyUpgradeService Property bool CanAutomaticallyUpgradeService() {get} {set}
ClientApplicationID Property string ClientApplicationID() {get} {set}
IgnoreDownloadPriority Property bool IgnoreDownloadPriority() {get} {set}
IncludePotentiallySupersededUpdates Property bool IncludePotentiallySupersededUpdates() {get} {set}
Online Property bool Online() {get} {set}
SearchScope Property SearchScope SearchScope() {get} {set}
ServerSelection Property ServerSelection ServerSelection() {get} {set}
ServiceID Property string ServiceID() {get} {set}
PS C:\>
Vous pouvez continuer à utiliser get-member pour découvrir toutes les différentes options et essentiellement secrète que VBScript dans PowerShell et apportez des modifications à faire tout Vous en avez besoin.
Andy