cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Bert_D
Lansweeper Employee
Lansweeper Employee

The below script will clear the anti-virus WMI class in the SecurityCenter or SecurityCenter2 namespace, depending on the Windows OS. After a reboot of the client machine, WMI will rebuild this class.

If you're running this script as a deployment package:

  • Copy the code below and save it as DelWMIAntivirus.vbs in the Program Files (x86)\Lansweeper\PackageShare\Scripts folder on your Lansweeper server.
  • Run the deployment package under your scanning credentials.

 

On Error Resume Next

Set shell = CreateObject("WScript.Shell")
Set getOSVersion = shell.exec("%comspec% /c ver")
version = getOSVersion.stdout.readall

Select Case True
Case InStr(version, "n 5.") > 1 : GetOS = 0 'Windows XP
Case InStr(version, "n 6.") > 1 : GetOS = 1 'Windows Vista, 7, 8, 8.1
Case InStr(version, "n 10.") > 1 : GetOS = 1 'Windows 10
Case Else : GetOS = -1
End Select

strComputer = "."
If GetOS = 0 Then
Set oWMI = GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\SecurityCenter")

Set colItems = oWMI.ExecQuery("Select * from AntiVirusProduct")

For Each objItem In colItems
objItem.Delete_
Next
End If

If GetOS = 1 Then
Set oWMI = GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\SecurityCenter2")

Set colItems = oWMI.ExecQuery("Select * from AntiVirusProduct")

For Each objItem In colItems
objItem.Delete_
Next

End If