如何通过命令提示符启用或禁用网络适配器

1、点击任务栏搜索框或搜索图标,输入CMD,选择以管理员身份运行

2、键入以下命令,然后按Enter键以在您的计算机上显示网络适配器的名称:

netsh interface show interface

3、键入以下命令以禁用Wi-Fi或以太网适配器,然后按Enter:

netsh interface set interface "适配器名称" disable。

比如我使用的是“以太网”则添加“以太网”即:

netsh interface set interface "以太网" disable

如我使用的是“WLAN”则添加“WLAN”即:

netsh interface set interface "WLAN" disable

4、若要启用网络适配器,使用上述相同方法,在第三步,输入以下点按Enter即可。

netsh interface set interface "以太网" enable

5、编写到cpp中可采用以下即可

#include "stdio.h"
#include <windows.h>
int main(int argc, char **argv)
{
char argdata[1024] = " interface set interface \"WLAN\" disable";
ShellExecute(NULL, NULL, "netsh", argdata, NULL, SW_HIDE);
return 0;
}