首页 > 技术文章 > 利用devcon工具编写bat脚本一键控制系统设备,如开启关闭网卡

yeni 2019-03-07 08:48 原文

系统WIN7 x64位

下载devcon命令行工具

  1. Download the “Windows Driver Kit (WDK) 7.1.0 from Microsoft: http://www.microsoft.com/download/en/details.aspx?id=11800
  2. Extract the ISO to a temp directory with WinRAR, Uniectractor
  3. Extract the install file “WDK\setuptools_x64fre.msi” to a temp directory, where you will find “WinDDK\7600.16385.win7_wdk.100208-1538\tools\devcon\amd64\devcon.exe”
  4. 将devcon 复制到 C:\Windows\System32
  • 注意: devcon MUST be run from an administrator cmd win *

查找网卡设备信息

  1. 使用管理员运行cmd
  2. 列出全部的PCI设备信息
    devcon find PCI\*
  3. 记下网卡的信息,如

PCI\VEN_8086&DEV_15B7&SUBSYS_06B91028&REV_31\3&11583659&0&FE: Intel(R) Ethernet Connection (2) I219-LM

编写bat脚本

@echo off
devcon enable *DEV_15B7*
echo on
@echo off
devcon disable *DEV_15B7*
echo on

推荐阅读