Click here to Skip to main content
15,878,970 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
I want to get the details of Installed antivirus in system i can get the details from Window 7 but Cant from Windows XP m using below code for fetching data



C#
string wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
ManagementObjectCollection mObject = searcher.Get();
if (mObject.Count == 0)
{
    wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter2";
    searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
    mObject = searcher.Get();
}
if (mObject.Count > 0)
{
    foreach (ManagementObject obj in mObject)
    {
        SysInfo = "insert into [dbo].[AntiVirus]  obj["disName"].ToString() + "','" + obj["instGuid"].ToString() + "','" + obj["SgdPrdctExe"].ToString() + "','" + obj["prdctState"].ToString() + "')";
        break;
    }
}
else
{
    SysInfo = "insert into [dbo].[AntiVirus] [disName]) values('" + MA + 'No AntiVirus')";
}
Posted
Updated 27-Oct-13 18:45pm
v2

1 solution

As I see, you made it right, although the decision to query one or the other class, should depend on the OS version (see: http://gallery.technet.microsoft.com/scriptcenter/Get-the-status-of-4b748f25). I have no XP to test, but if the OS is reporting antivirus status correctly in the security center, you should be able to get it with WMI. If security center does not see the software properly, you can't get it with WMI this way. I suggest you try WMI explorer[^] to get in idea in-vivo, before coding it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900