Hello All,

I'm trying to turn on/off the firewall on other machines connected to the same active directory , But getting the below error

Retrieving the COM class factory for remote component with CLSID {E2B3C97F-6AE1-41AC-817A-F6F92166D7DD} from machine 10.180.7.1 failed due to the following error: 80070005.

Below is the code and I've googled this error and tried changing the DCom component under component services on my machine. Can anyone please guide me in resolving this error?

 
 
C#
 class Class6
    {
        private static INetFwPolicy2 getCurrPolicy()
        {
            INetFwPolicy2 fwPolicy2;
            Type tNetFwPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2", "10.180.7.1", false);
                           if (tNetFwPolicy2 != null)
                    fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(tNetFwPolicy2);
                else
                    return null;
                return fwPolicy2;

        }

        public static void GetFS()
        {
            bool result = false;
            try
            {
                INetFwPolicy2 fwPolicy2 = getCurrPolicy();
                NET_FW_PROFILE_TYPE2_ fwCurrentProfileTypes;
                //read Current Profile Types (only to increase Performace)
                //avoids access on CurrentProfileTypes from each Property
                fwCurrentProfileTypes = (NET_FW_PROFILE_TYPE2_)fwPolicy2.CurrentProfileTypes;
                //result = (fwPolicy2.get_FirewallEnabled(fwCurrentProfileTypes));
                result = (fwPolicy2.get_FirewallEnabled(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_DOMAIN));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            if(result)
            { SetFirewallStatus(result); }
        }
        public static void SetFirewallStatus(bool newStatus)
    {
        try
        {
            INetFwPolicy2 currPolicy = getCurrPolicy();
            currPolicy.set_FirewallEnabled(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_DOMAIN, false);

        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
    }
    }