[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. Option Explicit
  2. ' On Error Resume Next
  3. Dim strDriveLetter,objWbemService,colVolumes,objVolume
  4. strDriveLetter = "D"
  5. Set objWbemService = GetObject("winmgmts:{ImpersonationLevel=Impersonate}!//./root/cimv2")
  6. Set colVolumes = objWbemService.ExecQuery("Select DeviceID,DriveLetter,Label,Name,SerialNumber From Win32_Volume Where BootVolume=False And SystemVolume=False And DriveType=3")
  7. For Each objVolume In colVolumes
  8. '系统盘卷标是Win7 或 Win10
  9.   If LCase(Left(objVolume.Label,3)) = "win" Then
  10.     objVolume.Dismount True,True
  11.     ' ShowError
  12.   Else
  13.     If UCase(Left(objVolume.DriveLetter,1)) <> strDriveLetter Then
  14.       objVolume.DriveLetter = strDriveLetter & ":"
  15.     End If
  16.     If strDriveLetter = "Z" Then Exit For
  17.     strDriveLetter = Chr(Asc(strDriveLetter) + 1)
  18.   End If
  19. Next
  20. Set objVolume = Nothing
  21. Set colVolumes = Nothing
  22. Set objWbemService = Nothing
复制代码

TOP

返回列表