none
Get Installed Anti-Virus & Status RRS feed

  • Question

  • I am trying to create a program that can detect what Anti-Virus is installed, and it's status.   I know I can look up all programs installed and try and guess names, but was wondering if there is anyway to call this info from the OS, similar to Security Center?

    Thanks in advance

    Monday, September 1, 2014 4:56 PM

Answers

  • Hi Joe,

    >>but was wondering if there is anyway to call this info from the OS, similar to Security Center?

    Yes, we can use the WMI making a connection to the root\SecurityCenter namespace (starting with windows Vista you must use the root\SecurityCenter2 namespace), and then query for the AntiVirusProduct WMI class, here is a sample code:

    Public Sub ListAntivirus()
            Dim av_searcher As New ManagementObjectSearcher("root\SecurityCenter2", "SELECT * FROM AntivirusProduct")
            For Each info As ManagementObject In av_searcher.Get()
                Console.WriteLine(info.Properties("displayName").Value.ToString())
    
                Dim AvStatus = Hex(info.Properties("ProductState").Value.ToString())
                If Mid(AvStatus, 2, 2) = "10" Or Mid(AvStatus, 2, 2) = "11" Then
                    Console.WriteLine("AntiVirus enabled" & vbCrLf)
                ElseIf Mid(AvStatus, 2, 2) = "00" Or Mid(AvStatus, 2, 2) = "01" Then
                    Console.WriteLine("AntiVirus disabled" & vbCrLf)
                End If
                Console.WriteLine("----------------------------" & vbCrLf)
    
            Next info
    End Sub

    The above code has been tested on Win8.1 machine, result as below:


    Here is a similar thread: http://social.msdn.microsoft.com/Forums/en-US/6501b87e-dda4-4838-93c3-244daa355d7c/wmisecuritycenter2-productstate?forum=vblanguage


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Blackwood Tuesday, September 2, 2014 1:42 PM
    • Marked as answer by Joe Medford Wednesday, September 3, 2014 4:23 PM
    Tuesday, September 2, 2014 10:51 AM
    Moderator

All replies

  • Hello,

    To do such a task you would need API access to whatever Anti-Virus software was installed for their status.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Monday, September 1, 2014 10:20 PM
    Moderator
  • how about what AV is installed?
    Tuesday, September 2, 2014 12:06 AM
  • how about what AV is installed?

    Multiple AV's could be installed. The issue would be to know which is being used by the system.

    La vida loca

    Tuesday, September 2, 2014 2:08 AM
  • If more then one is installed can I get both of them listed?
    Tuesday, September 2, 2014 2:42 AM
  • Hi Joe,

    >>but was wondering if there is anyway to call this info from the OS, similar to Security Center?

    Yes, we can use the WMI making a connection to the root\SecurityCenter namespace (starting with windows Vista you must use the root\SecurityCenter2 namespace), and then query for the AntiVirusProduct WMI class, here is a sample code:

    Public Sub ListAntivirus()
            Dim av_searcher As New ManagementObjectSearcher("root\SecurityCenter2", "SELECT * FROM AntivirusProduct")
            For Each info As ManagementObject In av_searcher.Get()
                Console.WriteLine(info.Properties("displayName").Value.ToString())
    
                Dim AvStatus = Hex(info.Properties("ProductState").Value.ToString())
                If Mid(AvStatus, 2, 2) = "10" Or Mid(AvStatus, 2, 2) = "11" Then
                    Console.WriteLine("AntiVirus enabled" & vbCrLf)
                ElseIf Mid(AvStatus, 2, 2) = "00" Or Mid(AvStatus, 2, 2) = "01" Then
                    Console.WriteLine("AntiVirus disabled" & vbCrLf)
                End If
                Console.WriteLine("----------------------------" & vbCrLf)
    
            Next info
    End Sub

    The above code has been tested on Win8.1 machine, result as below:


    Here is a similar thread: http://social.msdn.microsoft.com/Forums/en-US/6501b87e-dda4-4838-93c3-244daa355d7c/wmisecuritycenter2-productstate?forum=vblanguage


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Blackwood Tuesday, September 2, 2014 1:42 PM
    • Marked as answer by Joe Medford Wednesday, September 3, 2014 4:23 PM
    Tuesday, September 2, 2014 10:51 AM
    Moderator
  • I wrote similar code before, but I get errors on ManagementObjectSearcher saying it is not defined.   I have searched online, but have not found a clear answer to what I have to declare.   THanks
    Wednesday, September 3, 2014 12:26 AM
  • Figured it out,  did not add, Imports System.Management  and didn't add the System.Managment reference into the project.   Always seem to forget that one.    Thanks
    Wednesday, September 3, 2014 12:38 AM
  • If your question is answered, you should mark one of the replies as the answer so that someone with a similar question will find it when searching.
    Wednesday, September 3, 2014 1:26 PM