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

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.
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:
    617
    KE7LYS
    May 7, 2007
  2. francois

    custom property set for AVSTREAM minidriver

    francois, Jul 11, 2005, in forum: Windows Vista Drivers
    Replies:
    2
    Views:
    790
    francois
    Jul 11, 2005
  3. news.microsoft.com

    DHTML property set cell backgroundImage

    news.microsoft.com, Jul 28, 2006, in forum: Internet Explorer
    Replies:
    0
    Views:
    176
    news.microsoft.com
    Jul 28, 2006
  4. Keith Hill

    MSH: get/set-property names are confusing

    Keith Hill, Jan 5, 2006, in forum: Scripting
    Replies:
    7
    Views:
    382
    Keith Hill [MVP]
    Jan 7, 2006
  5. Andrew Watt [MVP]

    [Monad] get-property -property parameter

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