Blog

Update Managed Antivirus

Here is a script that Updates MAV and resends the DSC information if required.

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
Dim WshShell, oExec, OsType, FSO, bResendDSC, MAVPath, AgentPath
 Set WshShell = CreateObject("WScript.Shell")
 Set FSO = CreateObject("Scripting.FileSystemObject")
 
 OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
 
 If OsType = "x86" then
     AgentPath = "C:\Program Files\"
 elseif OsType = "AMD64" then
     AgentPath = "C:\Program Files (x86)\"
 end if
 
 If FSO.FolderExists(AgentPath & "Advanced Monitoring Agent") Then
     AgentPath = AgentPath & "Advanced Monitoring Agent"
 ElseIf FSO.FolderExists(AgentPath & "Advanced Monitoring Agent GP") Then
     AgentPath = AgentPath & "Advanced Monitoring Agent GP"
 Else
     wscript.Echo "Agent Folder Not Found."
 End If
 
 MAVPath = Chr(34) & AgentPath & "\managedav\SBAMCommandLineScanner.exe" & Chr(34) & " /updatedefs"
 AgentPath = Chr(34) & AgentPath & "\winagent.exe" & Chr(34)
 
 bResendDSC = True
 Set oExec = WshShell.Exec(MAVPath)
 
 Do While oExec.Status <> 1
     WScript.Sleep 100
 Loop
 
 Do While oExec.StdOut.AtEndOfStream <> True 
     If oExec.StdOut.ReadLine = "DONE:Update not needed" Then
         bResendDSC = False
     End If
 Loop
 
 If bResendDSC = True Then 
     RestartDSC
     wscript.Echo "Updating MAV and resending DSC"
 Else
     wscript.Echo "MAV is up to date"
 End If
 
 Sub RestartDSC()
     'Stop agent Service
     Set oExec = WshShell.Exec(AgentPath & " /stopservice")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 
     'Reset DSC Counter
     Set oExec = WshShell.Exec(AgentPath & " /testreset")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 
     'Restart Service
     Set oExec = WshShell.Exec(AgentPath & " /startservice")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 End Sub

Posted in: Scripts, Technical

Leave a Comment (3) ↓

3 Comments

  1. Joe May 19, 2013

    How do you add the script in GFI

    reply
    • Jake May 28, 2013

      Please refer the the GFI Documentation.

      reply
  2. Thane K. Sherrington October 17, 2016

    Does this work with the current Agent (2016) and both Vipre and BitDefender?

    reply

Leave a Comment