Detect installed Antivirus from code
October 31, 2010 1 Comment
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.