Bonjour

Je dois utiliser la librairie WUAlib de microsoft pour patcher des PC. Pour l'instant j'ai créer un exe que je déploie sur chaque machine et exécute pour installer les MAJ Microsoft. Hors sur leurs site
http://msdn.microsoft.com/en-us/libr...88(VS.85).aspx
il semblerait que l'on puisse utiliser WUA pour exécuter le code à partir d'un PC distant. (pour ma part cela serait une méthode dans un webservice.)

Hors je ne comprend pas du tout comment ils utilisent ces interfaces pour se connecter à la machine distante (par exemple dans le Isession je ne vois pas ou j'indique l'ip ou le nom de la machine à laquelle je veut me connecter).
Ce dessous le code que j'utilise dans mon exe pour l'installation de patch.
Pourriez vous me dire si ce que j'ai compris est vrai: CAD qu'à partir de mon webservice je peux lancer l'install sur un PC distant.
Merci de votre aide

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
            'New session
            Dim updateSession As New WUApiLib.UpdateSession
 
            'Searcher and search string
            Dim usearch As New WUApiLib.UpdateSearcher
            ecrire("Searching for Updates...")
            Dim searchResult As WUApiLib.ISearchResult = usearch.Search("IsInstalled = 0 and IsAssigned = 1 and Type='Software'")
            If searchResult.Updates.Count > 0 Then
                ecrire("Updates Found:")
                For a As Integer = 0 To searchResult.Updates.Count - 1
                    ecrire("Update Found:" & searchResult.Updates(a).Title.ToString)
                Next
                Dim updatesToDownload As WUApiLib.UpdateCollection = New WUApiLib.UpdateCollection
                updatesToDownload = searchResult.Updates
 
                'Download updates
                Dim downloader As WUApiLib.UpdateDownloader = updateSession.CreateUpdateDownloader
                downloader.Updates = updatesToDownload
                downloader.Download()
 
                ecrire("List of Downloaded updates...")
 
                'create update object
                For a As Integer = 0 To searchResult.Updates.Count - 1
                    If searchResult.Updates(a).IsDownloaded Then
                        ecrire(searchResult.Updates(a).Title.ToString)
                    End If
                Next
 
            Else
                ecrire("No Updates Found:")
            End If
 
            'Create collection
            ecrire("Creating update collection...")
 
            'Colection for installation
            ecrire("Creating collection with downloaded and installable updates:")
            Dim updatesToInstall = New WUApiLib.UpdateCollection
 
            For a As Integer = 0 To searchResult.Updates.Count - 1
                If searchResult.Updates(a).IsDownloaded Then
                    Dim update As WUApiLib.IUpdate = searchResult.Updates(a)
                    updatesToInstall.Add(update)
                    ecrire(searchResult.Updates(a).Title.ToString & "added")
                End If
            Next
 
            If updatesToInstall.Count < 1 Then
                ecrire("No updates to install")
                Exit Sub
            End If
 
            'Create installer
            Dim installer As WUApiLib.UpdateInstaller = updateSession.CreateUpdateInstaller
            installer.Updates = updatesToInstall
            installer.ForceQuiet = True
            ecrire("Installing updates")
            Dim result As WUApiLib.IInstallationResult = installer.Install()
 
            result.GetUpdateResult()
 
 
 
            ecrire(result.ResultCode.ToString())
 
            For i As Integer = 0 To updatesToInstall.Count - 1
                ecrire("Installation result for : " & updatesToInstall(i).Title.ToString & " = " & result.GetUpdateResult(i).ToString & " Code result = " & result.GetUpdateResult(i).ResultCode.ToString & " Reboot required = " & result.GetUpdateResult(i).RebootRequired.ToString)
                '                Console.WriteLine("Installation result for : " & updatesToInstall(i).Title.ToString & " = " & result.GetUpdateResult(i).ToString & " Code result = " & result.GetUpdateResult(i).ResultCode.ToString & " Reboot required = " & result.GetUpdateResult(i).RebootRequired.ToString)
            Next
            ecrire("-------------------------------")
            ecrire("Result for the whole update (ResultCode)" & result.ResultCode)
            ecrire("Result for the whole update (RebootRequired)" & result.RebootRequired.ToString)
            ecrire("Result for the whole update (HResult)" & result.HResult)
 
        Catch ex As Exception
            ecrire("An error happened" & ex.ToString)
        End Try
 
    End Sub