My account has administrative privileges. I access WMI on a Windows 7 Enterprise VM with powershell as follows:
 Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct  -ComputerName $computername
and with C# as follows:
        string computer = Environment.MachineName;
        string wmipath = @"\\" + computer + @"\root\SecurityCenter2";
        try
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipath,
              "SELECT * FROM AntivirusProduct");
            ManagementObjectCollection instances = searcher.Get();
            //MessageBox.Show(instances.Count.ToString()); 
            foreach (ManagementObject queryObj in instances)
            {
                return queryObj[type].ToString();
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
However, the code in Powershell works always but the code in C# works only if I run the program as administrator explicitly. Can I add anything to the C# code so that it could run for a user with administrative right without starting the C# program explicitly as administrator?
 
     
     
    