可以用这个,启用或禁用某个设备
第五行deviceid是设备实例路径
获取方法:设备管理器选中设备->右击属性->详细信息->属性选择设备实例路径->复制替换- @echo off
- %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","REM",,"runas",1)(window.close)&exit
- powershell -version 2.0 -c "Get-Content '%~0' | Select-Object -Skip 4 | Out-String | Invoke-Expression"
- pause&exit
- $DeviceId="USB\VID_8087&PID_0A2A\5&D027AA&0&7";
- $device=Get-WmiObject "CIM_LogicalDevice" | Where-Object { $_.DeviceId -eq $DeviceId}
- $device.Caption
- if($device.Status -eq "OK"){
- $device.Disable() | Out-Null
- if($?){"disable successful!"} else {"disable failed!"}
- } else {
- $device.Enable() | Out-Null
- if($?){"enable successful!"} else {"enable failed!"}
- }
复制代码
|