Detect installed Antivirus from code

It is possible to use System.Management class to efficiently query the operating system about several software and hardware information. One nice feature is the ability to retrieve the currently installed antivirus product along with detailed information about its status.

Fist, you need to add reference to System.Management namespace

Now import the Management namespace at the top of the form using the Imports keyword

Imports System.Management

Next, you need to add a button to your form and a listbox(just for display) then paste the below code inside the button1_click event. You can also wrap it up in a function if you intend to use it in several places:

Dim scope As New ManagementScope("\\.\root\SecurityCenter")
Dim searcher As New ManagementObjectSearcher("SELECT * FROM antivirusproduct")
Dim arInst As New ArrayList
searcher.Scope = scope
Dim av As ManagementObjectCollection = searcher.Get()
Dim Enumerator As ManagementObjectCollection. _
ManagementObjectEnumerator = av.GetEnumerator()
While Enumerator.MoveNext
    Dim avp As ManagementObject = CType(Enumerator.Current, ManagementObject)
End While

When you click on the button, the listbox will be filled with information about your installed antivirus product.