Advertisement
Guest User

Untitled

a guest
Sep 11th, 2010
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Management;
  4.  
  5. namespace ConsoleApplication1
  6. {
  7. class Program
  8. {
  9. public static bool AntivirusInstalled()
  10. {
  11.  
  12. string wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter";
  13. try
  14. {
  15. ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
  16. ManagementObjectCollection instances = searcher.Get();
  17. return instances.Count > 0;
  18. }
  19.  
  20. catch (Exception e)
  21. {
  22. Console.WriteLine(e.Message);
  23. }
  24.  
  25. return false;
  26. }
  27.  
  28. public static void Main(string[] args)
  29. {
  30. bool returnCode = AntivirusInstalled();
  31. Console.WriteLine("Antivirus Installed " + returnCode.ToString());
  32. Console.WriteLine();
  33. Console.Read();
  34. }
  35.  
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement