有没有办法使用 VBscript 检查 PS2 键盘 and/or PS2 鼠标是否连接到计算机 运行 Windows XP 或更高版本?
Is there a way using VBscript to check if PS2 keyboard and/or PS2 mouse are attached to a computer running Windows XP or above?
我有一个非常复杂的问题要问社区:
我必须管理一个拥有数百台 PC 运行 Win XP Pro SP3 的实验室。有时学生会断开键盘 and/or 鼠标与计算机的连接,所以在每次 class 之后我都必须检查每台机器并检查它们是否已安装,这让我浪费了很多时间。因此,我正在用 VBScript 编写一个脚本来检查机器,并将有关配置的信息放入数据库中,以帮助我判断机器是否有问题。现在,我还想检查 PS2 键盘 and/or PS2 鼠标是否已连接,这样我就可以在新的 class 开始之前立即恢复它们' 逐台尝试。我怎样才能做到这一点? WMI?如何?谢谢。
WMI should probably be able to provide this information. See this related question for examples. You will probably need Win32_Keyboard
and Win32_PointingDevice
, maybe Win32_PnPEntity
if those do not report disconnecting(我无法测试 PS/2 硬件)。
所有这些都应该翻译成 VBScript,也许使用 Microsoft 的 documentation about WMI from VBScript。首先:
On Error Resume Next
For Each strComputer In Array("localhost")
WScript.Echo "Computer: " & strComputer
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Keyboard", "WQL", &h30)
For Each objItem In colItems
WScript.Echo objItem.Availability, objItem.Caption, _
objItem.ConfigManagerErrorCode, objItem.ConfigManagerUserConfig, _
objItem.Description, objItem.DeviceID, _
objItem.ErrorCleared, objItem.ErrorDescription, _
objItem.IsLocked, _
objItem.LastErrorCode, _
objItem.Layout, _
objItem.Name, _
objItem.PNPDeviceID, _
objItem.Status, objItem.StatusInfo, _
objItem.SystemCreationClassName, objItem.SystemName
Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PointingDevice", "WQL", &h30)
For Each objItem In colItems
WScript.Echo objItem.Availability, objItem.Caption, _
objItem.ConfigManagerErrorCode, objItem.ConfigManagerUserConfig, _
objItem.Description, objItem.DeviceID, _
objItem.DeviceInterface, _
objItem.ErrorCleared, objItem.ErrorDescription, _
objItem.HardwareType, _
objItem.IsLocked, _
objItem.LastErrorCode, _
objItem.Name, _
objItem.PNPDeviceID, _
objItem.PointingType, _
objItem.Status, objItem.StatusInfo, _
objItem.Synch, _
objItem.SystemCreationClassName, objItem.SystemName
Next
Next
我有一个非常复杂的问题要问社区: 我必须管理一个拥有数百台 PC 运行 Win XP Pro SP3 的实验室。有时学生会断开键盘 and/or 鼠标与计算机的连接,所以在每次 class 之后我都必须检查每台机器并检查它们是否已安装,这让我浪费了很多时间。因此,我正在用 VBScript 编写一个脚本来检查机器,并将有关配置的信息放入数据库中,以帮助我判断机器是否有问题。现在,我还想检查 PS2 键盘 and/or PS2 鼠标是否已连接,这样我就可以在新的 class 开始之前立即恢复它们' 逐台尝试。我怎样才能做到这一点? WMI?如何?谢谢。
WMI should probably be able to provide this information. See this related question for examples. You will probably need Win32_Keyboard
and Win32_PointingDevice
, maybe Win32_PnPEntity
if those do not report disconnecting(我无法测试 PS/2 硬件)。
所有这些都应该翻译成 VBScript,也许使用 Microsoft 的 documentation about WMI from VBScript。首先:
On Error Resume Next
For Each strComputer In Array("localhost")
WScript.Echo "Computer: " & strComputer
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Keyboard", "WQL", &h30)
For Each objItem In colItems
WScript.Echo objItem.Availability, objItem.Caption, _
objItem.ConfigManagerErrorCode, objItem.ConfigManagerUserConfig, _
objItem.Description, objItem.DeviceID, _
objItem.ErrorCleared, objItem.ErrorDescription, _
objItem.IsLocked, _
objItem.LastErrorCode, _
objItem.Layout, _
objItem.Name, _
objItem.PNPDeviceID, _
objItem.Status, objItem.StatusInfo, _
objItem.SystemCreationClassName, objItem.SystemName
Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PointingDevice", "WQL", &h30)
For Each objItem In colItems
WScript.Echo objItem.Availability, objItem.Caption, _
objItem.ConfigManagerErrorCode, objItem.ConfigManagerUserConfig, _
objItem.Description, objItem.DeviceID, _
objItem.DeviceInterface, _
objItem.ErrorCleared, objItem.ErrorDescription, _
objItem.HardwareType, _
objItem.IsLocked, _
objItem.LastErrorCode, _
objItem.Name, _
objItem.PNPDeviceID, _
objItem.PointingType, _
objItem.Status, objItem.StatusInfo, _
objItem.Synch, _
objItem.SystemCreationClassName, objItem.SystemName
Next
Next