VBScript根据盘符找设备名的代码
程序员文章站
2022-07-06 12:57:24
复制代码 代码如下:on error resume nextstrcomputer = "." set objwmiservice = getobject("winmgmt...
复制代码 代码如下:
on error resume next
strcomputer = "."
set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2")
set colitems = objwmiservice.execquery( _
"associators of {win32_logicaldisk.deviceid='g:'} where resultclass=win32_diskpartition")
for each objitem in colitems
targetindex = objitem.diskindex
set items = objwmiservice.execquery( _
"select * from win32_diskdrive where deviceid like '%" & objitem.diskindex & "'",,48)
for each item in items
wscript.echo "model: " & item.model
next
next
上一篇: 去掉RAR右键解压菜单的VBS代码