萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> VBScript根據盤符找設備名的代碼

VBScript根據盤符找設備名的代碼

這篇文章主要介紹了vbs下通過盤符找設備名的實現代碼,需要的朋友可以參考下   復制代碼 代碼如下:


On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer & "rootCIMV2")
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

copyright © 萬盛學電腦網 all rights reserved