-1

I am looking for away to get this value:

I am building a program that will be installed on 100s of computers and servers. And i need to figure out how i can get the name of the anti virus in vb.net. This can also be a powershell script. It is possible to read the output from a powershell script in vb.net

The problem is: With all the scripts that I could find any where it was not able to even get my own antivirus. There needs to be a way to read the information from the control panel right? Or is that impossible.

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
  • For a C# example to reference, you can find one here: https://stackoverflow.com/a/41550931/2618670 – Edmund Dipple Apr 20 '18 at 10:18
  • @EdmundDipple That is one of the scrips that unfortunately doesn't work for my own antivirus software. That is the reason why I don't want to use it. But still thanks! any other idea's? – D. Teulings Apr 20 '18 at 11:02
  • Why exactly do you have the powershell tag on a question where you want a VB answer? – EBGreen Apr 20 '18 at 12:08
  • @EBGreen you can run an powershell script in vb.net and read the output – D. Teulings Apr 20 '18 at 12:58
  • PowerShell: [1](https://gallery.technet.microsoft.com/scriptcenter/Get-the-status-of-4b748f25), [2](https://janegilring.wordpress.com/tag/rootsecuritycenter2/) – beatcracker Apr 20 '18 at 20:02
  • @D.Teulings I am aware of that. You can run python from VB and get the output too. Or a myriad of other languages. I was just wondering since at no point in your actual post did you mention using Powershell. – EBGreen Apr 22 '18 at 16:50

1 Answers1

0

So after some searching i found this: with SecurityCenter2. For me this works

Dim IPAddress As String = "127.0.0.1"
        Dim connectionOptions As New ConnectionOptions()
        connectionOptions.EnablePrivileges = True
        connectionOptions.Impersonation = ImpersonationLevel.Impersonate

        Dim managementScope As New ManagementScope(String.Format("\\{0}\root\SecurityCenter2", IPAddress), connectionOptions)
        managementScope.Connect()

        Dim objectQuery As New ObjectQuery("SELECT * FROM AntivirusProduct")
        Dim managementObjectSearcher As New ManagementObjectSearcher(managementScope, objectQuery)
        Dim managementObjectCollection As ManagementObjectCollection = managementObjectSearcher.[Get]()

        Dim antivirus As String = ""

        If managementObjectCollection.Count > 0 Then
            For Each item As ManagementObject In managementObjectCollection
                antivirus = antivirus + item("displayName") + " - "
            Next
            antivirus = antivirus.Remove(antivirus.Count - 3, 3)
        End If