欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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