离开好久了,最近不是很好......好像我跑题了...
        废话完了,开始继续其他的废话:决定把前不久看到的一个软件贴出来下.主要是关于windows硬件设备的一些问题:enable/disable device (driver)
每次要启用禁用硬件设备,总是打开设备管理器,找到相应的设备,然后右键启用/禁用,很麻烦.比如现在笔记本都内置摄像头,不能像外接USB摄像头一样插拔了,每次不用的时候到设备管理器里面禁用,然后又反复的启用总感觉很麻烦.想写个程序或者写个批处理来实现.找到一个"微软出品,必属废品"的程序:DevCon.exe.这是个命令行工具.用作设备管理。它可以启用、禁用、重启、更新、删除、查询单个或一组设备,它还提供与设备驱动开发者有关的信息,这些信息在Windows设备管理器中是得不到的。DevCon.exe可以用在windowsXp、2000、2003中,不适用于Windows95/98/ME。DevCon.exe不随Windows分发,可以在微软网站上下载并免费使用。传送门:http://support.microsoft.com/kb/311272/zh-cn. 下载之后可以放在windows目录下面,以供CMD快捷调用.
        这里在windows xp sp3的环境下,以启用和禁用本机的摄像头为例,八一下DevCon.exe的使用.
        CMD下输入devcon help之后,软件会给出它的使用方法:
----------------------------------------------昏割线开始----------------------------------------------
Device Console Help:
devcon [-r] [-m:\\<machine>] <command> [<arg>...]
-r if specified will reboot machine after command is complete, if needed.
<machine> is name of target machine.
<command> is command to perform (see below).
<arg>... is one or more arguments if required by command.
For help on a specific command, type: devcon help <command>
classfilter          Allows modification of class filters.
classes              List all device setup classes.
disable              Disable devices that match the specific hardware or instance ID.
driverfiles          List driver files installed for devices.
drivernodes          Lists all the driver nodes of devices.
enable               Enable devices that match the specific hardware or instance ID.
find                 Find devices that match the specific hardware or instance ID.
findall              Find devices including those that are not present.
help                 Display this information.
hwids                Lists hardware ID's of devices.
install              Manually install a device.
listclass            List all devices for a setup class.
reboot               Reboot local machine.
remove               Remove devices that match the specific hardware or instance ID.
rescan               Scan for new hardware.
resources            Lists hardware resources of devices.
restart              Restart devices that match the specific hardware or instance ID.
sethwid              Modify Hardware ID's of listed root-enumerated devices.
stack                Lists expected driver stack of devices.
status               List running status of devices.
update               Manually update a device.
updateni             Manually update a device (non interactive).
----------------------------------------------昏割线结束----------------------------------------------
 
DevCon.exe原本就是一个增强型的设备管理器,所以我们常用的几个带参运行命令为:
devcon find获取硬件ID(Hardware ID)
for+find筛选来禁用或启用设备(enable/disable device)
devcon status 枚举运作中的设备
进入CMD,执行:devcon status * >>D:\device.text
将会在指定路径生成一个硬件信息列表(不同机器上生成的列表不同),CTRL+F查找cam(摄像头一般以cam示出),
        找到:
----------------------------------------------昏割线开始----------------------------------------------
USB\VID_04F2&PID_B071\SN0001
Name: USB 2.0 1.3M UVC WebCam
Device is disabled.
----------------------------------------------昏割线结束----------------------------------------------
我们取其设备ID:VID_04F2&PID_B071   (PS:这个硬件ID不同机器肯定不一样,不要照抄此处的ID)
        打开记事本,输入以下分割线内的代码,另存为:Disable Camera.bat,即是禁用摄像头.
----------------------------------------------昏割线开始----------------------------------------------
@echo off
devcon disable *vid_04f2*pid_b071*
----------------------------------------------昏割线结束----------------------------------------------
 
打开记事本,输入以下分割线内的代码,另存为:Enable Camera.bat,即是启用摄像头.
----------------------------------------------昏割线开始----------------------------------------------
@echo off
devcon enable *vid_04f2*pid_b071*
----------------------------------------------昏割线结束----------------------------------------------
其他诸如无线网卡,物理网卡,光驱等硬件以此类推.
END.


部分原创文章若需转载,请注明出处: 转载自 夜幕里的稻草人 [http://www.didodi.cn/]
本文链接地址:[http://www.didodi.cn/post/223.html]