For example you are building a Antivirus, and through your code you want to notify users that there is already an antivirus installed in the users system. This will be useful because user might not want to install ore than one antivirus in the system. This is one of the scenario where you want to know if the antivirus is installed or not, but there can be more such examples.
In Windows, you have Windows Management Instrument (WMI) from where you can get the information about the antivirus installed. In C# we need to search for "Antivirus Product" using ManagementObjectSearcher class as shown below :
We will be using public ManagementObjectSearcher(string scope, string queryString); where we will pass the scope in which to query and the query to be invoked.
Full Code :
static void Main(string args)
// We are searching for Antivirus Product in Security Center
using (var antiVirusSearch = new ManagementObjectSearcher(@"\\" + Environment.MachineName + @"\root\SecurityCenter2", "Select * from AntivirusProduct"))
var getSearchResult = antiVirusSearch.Get();
foreach (var searchResult in getSearchResult)
Console.WriteLine("Antivirus Name : " + searchResult["displayName"].ToString());
Console.WriteLine("Path : " + searchResult["pathToSignedProductExe"].ToString());
Please Like and Share the CodingDefined Blog, if you find it interesting and helpful.