Function ShowDriveType(objdrive)
Dim fso, d, t, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(objdrive)
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
s = "Drive: " & d.DriveLetter & "(" & d.VolumeName & "); Type: " & t
Wscript.Echo s
End Function
Set fso = CreateObject("Scripting.FileSystemObject")
Set objdrives=fso.Drives
For Each objdrive In objdrives
ShowDriveType(objdrive)
Next
对于你的问题:
Dim drvName, drv
Set fso = CreateObject("Scripting.FileSystemObject")
drvName = left(Wscript.ScriptFullName, 1)
Set drv = fso.GetDrive(drvName)
If drv.DriveType <> 1 Then
msgbox "当前盘 " & Ucase(drvName) & ":\ 盘不是可移动盘,请在移动盘下执行本程序", 16, "警告"
Wscript.Quit
End If
msgbox "这下面是一些基于可移动磁盘 " & Ucase(drvName) & ":\ 的命令。", 64, "完成"
Last edited by qinchun36 on 2009-9-1 at 23:29 ]