也许是好东西——Windows Script Host-3[获取硬盘分区信息]

80酷酷网    80kuku.com

  window|硬盘'************************************************
' File:    GetDriveX.vbs (WSH sample in VBScript)
' Author:  (c) G. Born
'
' Showing the properties of a drive by using
' FileSystemObject
'************************************************
Option Explicit

' Drive type constants
Const Unknown = 0
Const Removable = 1  ' Removable medium
Const Fixed = 2      ' Fixed medium (hard disk)
Const Remote = 3     ' Network drive
Const CDROM = 4      ' CD-ROM
Const RAMDisk = 5    ' RAM disk

Dim Text, Title, drive
Dim fso, oDrive                 ' Object variable

Dim drtype(6)
drtype(0) = " Unknown "
drtype(1) = " Removable "
drtype(2) = " Fixed "
drtype(3) = " Remote "
drtype(4) = " CDROM "
drtype(5) = " RAMDisk "

Text = "Drive" & vbCrLf & vbCrLf
Title = "WSH sample - by G. Born"

drive = ""
Do                      ' Query drive letter.
    drive = InputBox("Drive letter (e.g. A)", "Drive", "C")

    If drive = "" Then  ' Test for Cancel button.
        WScript.Quit
    End If

    drive = Left(drive, 1)  ' Extract drive letter.
    
    ' Valid drive name (between A and Z)?
    If Asc(UCase(drive)) < Asc("A") Or _
       Asc(UCase(drive)) > Asc("Z") Then
        MsgBox "Drive " & drive & " is illegal"
        drive = ""
    End If
Loop Until drive <> ""

' Create FileSystemObject object to access the file system.
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

' Check whether drive exists.
If (Not fso.DriveExists(drive)) Then
    WScript.Echo "The drive " & drive & " doesn't exist"
    WScript.Quit
End If

Set oDrive = fso.GetDrive(drive)    ' Get Drive object.

If (oDrive.IsReady) Then
    Text = Text & UCase(drive) & " - " & oDrive.VolumeName & vbCrLf
    Text = Text & "Drive type: " & drtype(oDrive.DriveType) & vbCrLf
    Text = Text & "File system: " & oDrive.FileSystem & vbCrLf
    Text = Text + "Capacity: " & _
        FormatNumber(oDrive.TotalSize/(1024*1024), 0) & _
        " MB" & vbCrLf
    Text = Text & "Free: " & FormatNumber(oDrive.FreeSpace/1024, 0) _
           & " KB" & vbCrLf
Else
    Text = Text & "Drive not ready" & vbCrLf
End If

MsgBox Text, vbOKOnly + vbInformation, Title

'*** End

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: