HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: naps1saps on March 08, 2014, 04:57:21 AM

Title: Can I disable network interface in the security module?
Post by: naps1saps on March 08, 2014, 04:57:21 AM
I would like to disable the network adapter if no internet connection is present so my cell data modem will connect to send alerts if the cable is cut or power is out.  Found some code but it will not run probably because it needs some includes or uses data.  Also I need a ping statement if possible.

METHOD 1
Code: [Select]
Process.Start("cmd.exe","/c netsh interface set interface 'Local Area Connection' DISABLED");
METHOD 2
Must declare System.Management
Code: [Select]
SelectQuery wmiQuery = new SelectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId != NULL");
ManagementObjectSearcher searchProcedure = new ManagementObjectSearcher(wmiQuery);
foreach (ManagementObject item in searchProcedure.Get())
{
    if (((string)item["NetConnectionId"]) == "Local Network Connection")
    {
       item.InvokeMethod("Disable", null);
    }
}
Title: Re: Can I disable network interface in the security module?
Post by: naps1saps on March 12, 2014, 02:22:11 AM
Anyone know how to get this code to run in the module?