How to register my Winforms Application as antivirus in WMI using c#?

165 Views Asked by At

I have been creating an Antivirus application using ClamAV for the past few months, the application works fine.

I have another software which detects for the Security, Spywares and Firewall installed in the machine. On running a scan it detects ESAT Smart Security 8.0 which is already installed on my machine, whereas my antivirus is not in the list. On doing some research I found out that this chunk of code detects the existence of Antivirus in a machine.

ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(@"\\MyMachineName\root\SecurityCenter2", "SELECT * FROM AntivirusProduct");
ManagementObjectCollection objectCollection = managementObjectSearcher.Get();
string DisplayName = String.Empty;
 if (managementObjectSearcher.Get().Count > 0)
 {
    foreach (ManagementObject managementObject in managementObjectSearcher.Get())
        {

            DisplayName = managementObject["displayName"].ToString();

        }
 }

Now i do believe that in order to make my application look like an Antivirus I would have to make some entries into the SecurityCenter2 or WMI. I tried the following code to achieve it

public static void RegisterAsAntivirus()
        {
            string computer = Environment.MachineName;
            string wmipath = @"\\" + computer + @"\root\SecurityCenter2";

            ManagementScope oScope = new ManagementScope(wmipath);
            oScope.Connect();
            ManagementPath oPath = new ManagementPath("AntivirusProduct");
            ObjectGetOptions oGetOp = new ObjectGetOptions();
            ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);
            PropertyDataCollection p = oProcess.Properties;

            // Obtain in-parameters for the method
            oProcess.SetPropertyValue("displayName", "antivirusname");
            oProcess.SetPropertyValue("instanceGuid", "guid");
            oProcess.SetPropertyValue("pathToSignedProductExe", @"path");
            oProcess.SetPropertyValue("pathToSignedReportingExe", "");
            oProcess.SetPropertyValue("productState", 266240);
            oProcess.Put();
        }

But even the above lines of code dont work for me. And I'm still at the same level. Any help in this aspect would be really appreciated.

My machine run on Windows 7 and the c# is my programming language.

0

There are 0 best solutions below