Unable to set INetFWRule Interfaces property

Discussion in 'Windows Vista Security' started by Anant, May 20, 2009.

  1. Anant

    Anant Guest

    Hi,
    Apologies if this is not the correct place to post this message.

    I want to set firewall rule programmatically on just one Network Interface
    card identified by its Guid.

    I have the valid guid and i want to assign it to Interfaces property, I
    don't get compilation error but during run time i get "Value does not fall
    within the expected range."

    Here's a piece of my code snippet.

    INetFwRule NewFwRule = null;
    Type typeFWRule = Type.GetTypeFromProgID("HNetCfg.FWRule");
    NewFwRule = (INetFwRule)Activator.CreateInstance(typeFWRule);
    Guid = {<<valid Guid of my wireless card>>}
    if (NewFwRule != null)
    {
    NewFwRule.Name = ruleName;
    NewFwRule.Description = ruleDesc;
    NewFwRule.ApplicationName = applnName;
    //NewFwRule.serviceName ="AthHostService";
    NewFwRule.Protocol = protocol;
    NewFwRule.LocalPorts = localPorts;
    NewFwRule.Grouping = ruleGrouping;
    NewFwRule.Profiles = CurrentProfilesBitMask;
    NewFwRule.Action =
    NetFwTypeLib.NET_FW_ACTION_.NET_FW_ACTION_ALLOW;
    NewFwRule.Enabled = true;
    NewFwRule.InterfaceTypes = "Wireless";
    NewFwRule.Interfaces = Guid;//<<<----Exception comes here

    //Add the Firewall Rule
    if (fwPolicy2 != null)
    {
    fwPolicy2.Rules.Add(NewFwRule);
    }
    }

    Can anyone pls point out what is the mistake i am doing. Any help will be
    greatly appreciated.

    Thanks
    --
    Anant
     
    Anant, May 20, 2009
    #1
    1. Advertisements

  2. Anant

    partseven

    Joined:
    Dec 17, 2010
    Messages:
    1
    Likes Received:
    0
    Anant - did you ever solve what the problem here was?
     
    partseven, Dec 17, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.