2

I am creating a software which is detecting threats on system but it requires Microsoft Security Essentials to clean that system. So I want to know whether Microsoft Security Essentials is running on the system so I can use this utility to make my software work. I already got this solution to check whether Microsoft Security Essentials is installed but I need to know to whether it is running or not? Thank you in advance.

To Check Microsoft security essential I have implemented the following code

private static bool DoesMseExist()
    {
        string location = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
        using (RegistryKey localMachineX64View =
                     RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
                     RegistryView.Registry64))
        {
            using (RegistryKey rk = localMachineX64View.OpenSubKey(location))
            {
                foreach (string subKey in rk.GetSubKeyNames())
                {
                    using (RegistryKey productKey = rk.OpenSubKey(subKey))
                    {
                        if (productKey != null)
                        {
                            if (Convert.ToString(productKey.GetValue("DisplayName"))
                               .Contains("Microsoft Security Client"))
                            {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }
Ryan Emerle
  • 15,461
  • 8
  • 52
  • 69
RaviKant Hudda
  • 1,042
  • 10
  • 25
  • 1
    possible duplicate of [How can I know if a process is running?](http://stackoverflow.com/questions/262280/how-can-i-know-if-a-process-is-running) – user247702 Oct 20 '14 at 12:18
  • 2
    Use System.Management to query for the installed anti-malware product. Use the WMI Code Creator utility to experiment. Google "wmi query antivirus" to learn more. – Hans Passant Oct 20 '14 at 12:28
  • possible duplicate of [Check anti-virus status in C#](http://stackoverflow.com/questions/4750507/check-anti-virus-status-in-c-sharp) – Ryan Emerle Oct 20 '14 at 15:28

1 Answers1

0

I finally got the answer an it worked me fine.

Process[] processlist = Process.GetProcessesByName("msseces");;
foreach(Process theprocess in processlist){
   Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}
RaviKant Hudda
  • 1,042
  • 10
  • 25