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)
    arInst.Add(avp("displayName").ToString())
    arInst.Add(avp("companyName").ToString())
    arInst.Add(avp("versionNumber").ToString())
    arInst.Add(avp("productUptoDate").ToString())
    arInst.Add(avp("InstanceGUID").ToString())
End While
Me.ListBox1.Items.AddRange(arInst.ToArray)

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

One Response to Detect installed Antivirus from code

  1. Pingback: Retrieving antivirus info | Zavasky Answers

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: