我正在尝试编写一个脚本来检查设备当前是否处于错误级别(在设备管理器中有一个黄色的砰砰声)。我试图自动化的最终任务是安装驱动程序,检查它是否安装正确,卸载,然后再次检查以验证它是否已卸载。我已经弄清楚了大部分,但我在 WQL 查询方面遇到了问题。我可以查询是否有任何驱动程序的错误级别不是 0,并且我可以查询是否有任何驱动程序具有特定的设备 ID,但是当我尝试同时执行这两种操作时,它会失败并显示“drivertest.vbs(4,1) Microsoft VBSCript 运行时错误: type mismatch: '[string: "Select * from Win32_"]' 这是我的代码:
strComputer = "."
Set objWMIService = GetObject(_
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PnPEntity " _
& "WHERE ConfigManagerErrorCode <> 0" AND "WHERE objItem.DeviceID = 'acpi\int33d6'")
For Each objItem in colItems
Wscript.Echo "Class GUID: " & objItem.ClassGuid
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Device ID: " & objItem.DeviceID
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Wscript.Echo "Service: " & objItem.Service
Next