VBScript根据盘符找设备名的代码
程序员文章站
2022-04-10 13:41:30
复制代码 代码如下: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
下一篇: VBS For Next循环的陷阱分享