Maybe it's good stuff.--windows Script host-3[Get Hard disk partition information]

Source: Internet
Author: User
Tags file system odrive
window| hard Drive ' ************************************************
' 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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.