Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   vbscript drive letter script :) (http://www.go4expert.com/forums/vbscript-drive-letter-script-t10459/)

luked 8May2008 09:21

vbscript drive letter script :)
 
hi all.
could sumone plz help me out with a script that,
a, ask for a drive letter
b, displays the type of drive
c, displayes its state (rdy or not rdy)
d, displays its serial no.
e, if no drive letter is entered or u hit esc or cancel the script should exit , saying no drive letter was entered.


i have looked everywhere for a script like this but havent found any
many thx in advance :)

SaswatPadhi 7May2009 20:40

Re: vbscript drive letter script :)
 
Here's you script :smile:

Code: vb

' First creat an FSO object
Set FSO = CreateObject("Scripting.FileSystemObject")

' Drive specifications
Dim Drv, DrvType, DrvName, DrvReady

' Get and format the drive name
InputBox("Please enter drive letter :", DrvName)
If Len(DrvName) > 1 Then DrvName = Left(DrvName,1)

' Check if user clicks "Cancel"
If DrvName = "" Then End

' Continue :)
Drv = FSO.GetDrive(DrvName)

Select Case Drv.DriveType
            Case 0: DrvType = "Unknown"
            Case 1: DrvType = "Removable"
            Case 2: DrvType = "Fixed"
            Case 3: DrvType = "Network"
            Case 4: DrvType = "CD-ROM"
            Case 5: DrvType = "RAM Disk"
End Select

If Drv.IsReady Then DrvReady = "Ready" Else DrvReady = "Not Ready"

MsgBox "Drive = " & DrvName & VbCrLf & "Drive Type = " & DrvType & VbCrLf &_
"Drive State = " & DrvReady & VbCrLf & "Volume Name = " & Drv.VolumeName



All times are GMT +5.5. The time now is 03:53.