提示: 以下代码在win7下能够成功启用/禁用网卡,但是在win8下无效 - /// <summary>
- /// 禁用网卡
- /// </summary>5
- /// <param name="netWorkName">网卡名</param>
- /// <returns></returns>
- private static bool DisableNetWork(ManagementObject network)
- {
- try
- {
- network.InvokeMethod("Disable", null);
- return true;
- }
- catch
- {
- return false;
- }
- }
- /// <summary>
- /// 启用网卡
- /// </summary>
- /// <param name="netWorkName">网卡名</param>
- /// <returns></returns>
- private static bool EnableNetWork(ManagementObject network)
- {
- try
- {
- network.InvokeMethod("Enable", null);
- return true;
- }
- catch
- {
- return false;
- }
- }
复制代码 |