Bonjour,

J'aurai besoin de votre aide car là je bloque

j'ai un script vbs qui me permet de savoir quel logiciel antivirus est installé s'il y en a un.

Dans un premier temps, je voudrais que ça écrive le résultat dans un fichier texte.

Dans un deuxième temps.
mais je sais pas si c'est possible c'est qu'il s’exécute sur plusieurs pc d'un réseaux a partir d'un fichier dans lequel j'aurais renseigne les machines.

Si vous avez une idée c'est cool.

voici le code

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
OPTION EXPLICIT
 
 
Dim args, objWMIService_AV, colItems, objAntiVirusProduct,strcompanyName,strdisplayName,strVersionNumber,strproductState,colItems2,PathToSignedProductExe
Dim colFiles,itemFile,strRunType, strFinalMessage, shell, ForAppend
 
'get the arguments
Set args = Wscript.Arguments
Set Shell = WScript.CreateObject("Scripting.FileSystemObject")
Set fichier = Shell.OpenTextFile("c:\temp\ecr.txt", ForAppend, True)
Set WshNetwork = WScript.CreateObject("WScript.Network")
 
If args.count = 1 Then
    strRunType = args(0)
Else
    'double-clicked the .vbs file
    strRunType = "MsgBox"
End If
 
Set objWMIService_AV = GetObject("winmgmts:\\.\root\SecurityCenter")
if err.number <> 0 Then
    Echo "      No AV registered to \root\SecurityCenter"
Else
    Set colItems = objWMIService_AV.ExecQuery("Select * from AntiVirusProduct")
 
    For Each objAntiVirusProduct In colItems
        Echo "      WARNING:  AV products registered to \root\SecurityCenter"
        strcompanyName = (objAntiVirusProduct.companyName)
        strdisplayName = (objAntiVirusProduct.displayName)
        strVersionNumber = (objAntiVirusProduct.versionNumber)
        strproductState = (objAntiVirusProduct.onAccessScanningEnabled)
 
        'Echo "      companyName:    " & strcompanyName
        Echo "      Antivirus:    " & strdisplayName
       ' Echo "      versionNumber:  " & strVersionNumber
        'Echo "      onAccessScanningEnabled:    " & strproductState
		Fichier.write( Now & " ---------- " &WshNetwork.ComputerName & " ---- " & strdisplayName & vbcrlf)
 
    Next
 
    Set objWMIService_AV = Nothing
 
End If
 
Err.Clear
 
 
Set objWMIService_AV = GetObject("winmgmts:\\.\root\SecurityCenter2")
If err.number <> 0 Then
    Echo "     No AV registered to \root\SecurityCenter2"
Else
    Set colItems2 = objWMIService_AV.ExecQuery("Select * from AntiVirusProduct")
 
    For Each objAntiVirusProduct In colItems2
        PathToSignedProductExe = Replace(objAntiVirusProduct.PathToSignedProductExe,"\","\\")
        'echo ("      Path " & PathToSignedProductExe)
        Set colFiles = objWMIService.ExecQuery ("Select * from CIM_Datafile Where name = '" & PathToSignedProductExe & "'",,48)
        For Each itemFile In colFiles 
            strcompanyName  = (itemFile.Manufacturer)
            strVersionNumber = (itemFile.Version)
            strdisplayName = (objAntiVirusProduct.displayName) 
            if (objAntiVirusProduct.ProductState = "266240" OR objAntiVirusProduct.ProductState = "266256") then 
                strproductState = "Scanning Enabled"
            Elseif (objAntiVirusProduct.ProductState = "262144") Then
                strproductState = "Scanning Not Enabled"
            Else
                strproductState = "Unknown State"
            End If
 
            'Echo "      WARNING:  AV products registered to \root\SecurityCenter2"
            'Echo "      strcompanyName: " & strcompanyName
            Echo "      Antivirus: " & strdisplayName
            'Echo "      strVersionNumber:   " & strVersionNumber
            'Echo "      strproductState:    " & strproductState
			Fichier.write( Now & " ---------- " &WshNetwork.ComputerName & " ---- " & strdisplayName & vbcrlf)
        Next
    Next
End If
 
 
'Final Cleanup
Call FinalCleanup
On Error Goto 0
 
 
Public Sub Echo (msg)
    If strRunType = "MsgBox" Then
        strFinalMessage = strFinalMessage & vbCRLF & msg
    ElseIf UCASE(strRunType) = "ECHO" Then
        wscript.Echo msg
    ElseIf UCASE(strRunType) = "INSTALLER" Then
        'THIS IS NOT YET IMPLEMENTED
        wscript.quit(1)
    End If
End Sub
 
Public Sub FinalCleanup
    If strRunType = "MsgBox" Then
        msgbox strFinalMessage
    End If
End Sub