Update Managed Antivirus

Table of Contents

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

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
 

Our Services