Unable to set INetFWRule Interfaces property

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

  1. Anant

    Anant Guest

    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 =
    NewFwRule.Enabled = true;
    NewFwRule.InterfaceTypes = "Wireless";
    NewFwRule.Interfaces = Guid;//<<<----Exception comes here

    //Add the Firewall Rule
    if (fwPolicy2 != null)

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

    Anant, May 20, 2009
    1. Advertisements

  2. Anant


    Dec 17, 2010
    Likes Received:
    Anant - did you ever solve what the problem here was?
    partseven, Dec 17, 2010
    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.