wifi无线网络连接定时器
在许多情况下,我需要控制我的电脑上的Wi-Fi状态。调整开/关自动[午夜>今早]好了,因为我的ISP并没有发票上的流量在该时间间隔,以及一些程序需要/使用大量的数据..
简单的方法是使用命令提示符cmd.exe的
netsh.exe中做这项工作。[ 下管理员权限] *
启用接口: netsh接口设置界面“INTERFACENAME”启用
禁用接口:netsh接口设置界面“INTERFACENAME”禁用
使用代码
总之运行此命令在C#。通过启动netsh.exe中处理多达解释参数:
private enum Status
{
    Online,
    Offline
}
private static void SetStatus(string interfaceName, Status status)
{
    string state = status == Status.Online ? "enable" : "disable";
    string arguments = "interface set interface \"{0}\" {1}";
    string args = string.Format(arguments, interfaceName, state);
    var NetshStartInfo = new System.Diagnostics.ProcessStartInfo("netsh", args)
    {
        CreateNoWindow = true,
        RedirectStandardOutput = true,
        UseShellExecute = false,
        WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
    };
    var Netsh = new System.Diagnostics.Process
    {
        StartInfo = NetshStartInfo
    };
    Netsh.Start();
}        
以管理员权限运行,添加到app.manifest文件在解决方案资源管理器这行代码到:<asmv1:assembly ...>  
<.../>      
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
      </requestedPrivileges>
    </security> 
</trustInfo>
</asmv1:assembly>
用法是有一定的限制和条件。先进的解决方案可以通过对某些程序调度的防火墙规则,并与参数等开始他们。  相关推荐
  spartmap    2020-06-10  
   libowenhit    2020-06-10  
   atb    2020-05-27  
   comeonxueRong    2020-05-15  
   河的第三条岸    2020-05-08  
   大老张学编程    2020-04-10  
   80304053    2020-03-28  
   LUOPING0    2020-03-28  
   NeverAgain    2020-03-27  
   zmjzhangmj    2020-02-18  
   84931231    2020-02-17  
   shenghua    2013-03-27  
   LychieFan    2013-07-17  
   cavenick    2014-12-26  
   onlykg    2019-12-26  
   IsanaYashiro    2019-12-15  
   tycoon    2019-11-27  
   RayDon    2013-08-11  
  
 