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
    Anant - did you ever solve what the problem here was?
     
    partseven, Dec 17, 2010
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KE7LYS

    How to set file property # to a value > 99

    KE7LYS, Apr 28, 2007, in forum: Windows Vista File Management
    Replies:
    2
    Views:
    596
    KE7LYS
    May 7, 2007
  2. francois

    custom property set for AVSTREAM minidriver

    francois, Jul 11, 2005, in forum: Windows Vista Drivers
    Replies:
    2
    Views:
    763
    francois
    Jul 11, 2005
  3. Andrew Watt [MVP]

    [Monad] get-property -property parameter

    Andrew Watt [MVP], Jan 30, 2006, in forum: Scripting
    Replies:
    9
    Views:
    562
    Keith Hill [MVP]
    Jan 31, 2006
  4. Alex K. Angelopoulos [MVP]
    Replies:
    6
    Views:
    762
    /\\/\\o\\/\\/
    Apr 7, 2006
  5. dreeschkind
    Replies:
    2
    Views:
    618
    dreeschkind
    Apr 14, 2006
Loading...