确认可移动磁盘是否准备就绪

Option Explicit Const Removable = 1 Const Exist = 1 Const NotExist = 0 Dim fso,AllDrives,EachDrive Set fso = CreateObject("Scripting.FileSystemObject") Set AllDrives = fso.Drives Dim Flag Flag = NotExist For Each EachDrive in AllDrives If EachDrive.DriveType = Removable Then Flag = Exist If EachDrive.IsReady = True Then MsgBox EachDrive & vbNewLine _ & "已准备就绪",64,"提示" Else MsgBox EachDrive & vbNewLine _ & "未准备就绪",64,"提示" End If End IF Next If Flag = NotExist Then MsgBox "未发现可移动磁盘",64,"提示" End If

 

 

 

这是我这两个星期学期VBS的研究成果之一,呵呵,其实只是把书上讲的属性、方法简单的用了一下,希望对那些学习VBS的人也会有帮助把

你可能感兴趣的:(each,磁盘)