Check antivirus installation in windows using wmi in vb.net programmatically

Using wmi in vb.net programmatically,this article will tell you how to check if antivirus is installed or not,the name of the antivirus product and the status of the antivirus, if the antivirus is enabled or disabled and updated or not updated

The appendOutput function in the example below appends output to a rich text box,you may use some different function for the purpose.

Dim colItems = GetObject("winmgmts:\\.\root\SecurityCenter2").ExecQuery("Select * from AntivirusProduct")

    If colItems.count = 0 Then

        appendOutput("Antivirus Software : NOT installed")
    
    Else
        appendOutput("Antivirus Software : Installed")

        Dim intCounter = 1

        For Each objItem In colItems

            appendOutput("[ Antivirus : " & intCounter & " ]")

            appendOutput("Antivirus Name : " & objItem.displayName)
            
            'THE Antivirus STATUS ENABLED/DISABLED

            Dim AvStatus = Hex(objItem.ProductState)
                    
            If Mid(AvStatus, 2, 2) = "10" Or Mid(AvStatus, 2, 2) = "11" Then
                        
                appendOutput("Antivirus Status : Enabled")

            ElseIf Mid(AvStatus, 2, 2) = "00" Or Mid(AvStatus, 2, 2) = "01" Then
                        
                appendOutput("Antivirus Status : Disabled")

            End If

            'THE Antivirus UPDATE STATUS ENABLED/DISABLED
            
             Dim AvCurrent = Hex(objItem.ProductState)

             If Mid(AvStatus, 4, 2) = "00" Then
                        
                  appendOutput("Antivirus Update Status : Updated")

             ElseIf Mid(AvStatus, 4, 2) = "10" Then
                        
                  appendOutput("Antivirus Update Status : Not Updated")

             End If

      intCounter += 1
      
      Next


That is all.

If you liked this article please do leave a reply and share it with friends.

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.